From c85b4627ae6a0f1602c112e3e9f5eb69f4ba8023 Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Wed, 8 Jul 2020 12:08:51 +0200 Subject: [PATCH 1/7] Added missing xml comments --- .../PdfInternals/Objects/IPdfObject.cs | 9 +++++++++ .../PdfInternals/Objects/Image.cs | 7 +++++++ .../PdfInternals/PdfReference.cs | 20 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/IPdfObject.cs b/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/IPdfObject.cs index c20890f..340f75f 100644 --- a/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/IPdfObject.cs +++ b/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/IPdfObject.cs @@ -3,9 +3,18 @@ namespace Synercoding.FileFormats.Pdf.PdfInternals.Objects { + /// + /// Interface representing a pdf object + /// public interface IPdfObject : IStreamWriteable, IDisposable { + /// + /// A pdf reference object that can be used to reference to this object + /// PdfReference Reference { get; } + /// + /// Indicator to check whether this object has been written to the PDF stream + /// bool IsWritten { get; } } } diff --git a/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/Image.cs b/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/Image.cs index 7da7f33..300aca3 100644 --- a/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/Image.cs +++ b/src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/Image.cs @@ -5,6 +5,9 @@ namespace Synercoding.FileFormats.Pdf.PdfInternals.Objects { + /// + /// A class representing an image + /// public class Image : IPdfObject, IDisposable { private readonly SixLabors.ImageSharp.Image _image; @@ -16,10 +19,13 @@ internal Image(PdfReference id, SixLabors.ImageSharp.Image image) _image = image; } + /// public PdfReference Reference { get; private set; } + /// public bool IsWritten { get; private set; } + /// public void Dispose() { if(!_disposed) @@ -29,6 +35,7 @@ public void Dispose() } } + /// public uint WriteToStream(Stream stream) { if(_disposed) diff --git a/src/Synercoding.FileFormats.Pdf/PdfInternals/PdfReference.cs b/src/Synercoding.FileFormats.Pdf/PdfInternals/PdfReference.cs index ff1763b..ebc1a98 100644 --- a/src/Synercoding.FileFormats.Pdf/PdfInternals/PdfReference.cs +++ b/src/Synercoding.FileFormats.Pdf/PdfInternals/PdfReference.cs @@ -1,18 +1,36 @@ namespace Synercoding.FileFormats.Pdf.PdfInternals { - public struct PdfReference + /// + /// A struct representing a reference + /// + public readonly struct PdfReference { + /// + /// Constructor for that uses generation 0 + /// + /// The id of the reference public PdfReference(int objectId) : this(objectId, 0) { } + /// + /// Constructor for + /// + /// The id of the reference + /// The generation of the reference public PdfReference(int objectId, int generation) { ObjectId = objectId; Generation = generation; } + /// + /// The object id of this reference + /// public int ObjectId { get; } + /// + /// The generation of this reference + /// public int Generation { get; } } } From b186424eb637ab7608ebba221c96e41e406657ef Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Wed, 8 Jul 2020 12:15:49 +0200 Subject: [PATCH 2/7] Updated license year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 0e6a18c..620872c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Gerard Gunnewijk +Copyright (c) 2020 Gerard Gunnewijk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 645eb4ffb8758d094de4ed624cb9b77a928283c5 Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Wed, 8 Jul 2020 12:16:09 +0200 Subject: [PATCH 3/7] Removed unused line from example --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index a108f41..defdd1b 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,6 @@ The sample project called *Synercoding.FileFormats.Pdf.ConsoleTester* uses multi
using (var fs = File.OpenWrite(fileName))
 using (var writer = new PdfWriter(fs))
 {
-    double _mmToPts(double mm) => mm / 25.4d * 72;
-
     writer
         .AddPage(page =>
         {

From 69aa6429f75aa9f6c0cd2d94a9ef218307c628e4 Mon Sep 17 00:00:00 2001
From: Gerard Gunnewijk 
Date: Wed, 8 Jul 2020 12:16:56 +0200
Subject: [PATCH 4/7] Moved project properties and itemgroups around

---
 Directory.Build.props                         | 32 ++++++++++++-------
 Directory.Build.targets                       |  7 ----
 src/Directory.Build.props                     |  5 +--
 src/Directory.Build.targets                   | 32 -------------------
 .../PackageDetails.props                      | 16 ++++++++++
 .../Synercoding.FileFormats.Pdf.csproj        | 18 ++++-------
 tests/Directory.Build.props                   |  1 -
 7 files changed, 43 insertions(+), 68 deletions(-)
 create mode 100644 src/Synercoding.FileFormats.Pdf/PackageDetails.props

diff --git a/Directory.Build.props b/Directory.Build.props
index f379b30..5e82b31 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,38 +6,33 @@
     $(SynercodingProjectCategory)/$(MSBuildProjectName)
     $(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/
     $(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/
-    $(BaseArtifactsPath)pkg/$(BaseArtifactsPathSuffix)/$(Configuration)/
+    $(BaseArtifactsPath)pkg/$(Configuration)/
   
 
   
     true
     portable
     full
-    enable
-    true
     false
     true
-    true
-    strict
+  
+  
+  
+    true
+    MIT
   
 
   
     Gerard Gunnewijk
     Synercoding
-    Synercoding.FileFormats.Pdf
     Copyright © $(Company)
   
 
-  
-    0.0.1
-    $(PackageVersion)
-    
-  
-
   
     en
     true
     git
+    https://github.com/synercoder/FileFormats.Pdf/
     
       https://api.nuget.org/v3/index.json;
       https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
@@ -47,6 +42,19 @@
 
   
     8.0
+    enable
+    true
+    strict
+  
+
+  
+    $(DefineConstants);SUPPORTS_HASHCODE
+  
+  
+    $(DefineConstants);SUPPORTS_HASHCODE
+  
+  
+    $(DefineConstants);SUPPORTS_HASHCODE
   
 
 
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 166772f..3586016 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -6,11 +6,4 @@
     $(DefineConstants);$(OS)
   
 
-  
-    
-    
-    
-    
-  
-
 
\ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index ebeb0be..9d4a858 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -2,6 +2,7 @@
 
 
   
+    netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.6
     $(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props
     src
   
@@ -15,9 +16,5 @@
   
     CS1591
   
-  
-  
-    netcoreapp3.1
-  
 
 
\ No newline at end of file
diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets
index 013a044..629e512 100644
--- a/src/Directory.Build.targets
+++ b/src/Directory.Build.targets
@@ -7,38 +7,6 @@
 
   
 
-  
-    $(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)
-  
-
-  
-    
-      false
-    
-  
-
-  
-
-  
-    
-      
-    
-    
-      
-    
-
-    
-      
-      
-    
-  
-
   
   
   
diff --git a/src/Synercoding.FileFormats.Pdf/PackageDetails.props b/src/Synercoding.FileFormats.Pdf/PackageDetails.props
new file mode 100644
index 0000000..c7fd528
--- /dev/null
+++ b/src/Synercoding.FileFormats.Pdf/PackageDetails.props
@@ -0,0 +1,16 @@
+
+
+  
+  
+    true
+  
+
+  
+    PDF
+    Synercoding.FileFormats.Pdf
+    Synercoding.FileFormats.Pdf
+    Contains classes which makes it easy to quickly create a pdf file.
+    Started using Synercoding.Primitives & updated SixLabors.ImageSharp.
+  
+
+
\ No newline at end of file
diff --git a/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj b/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj
index bb971ed..887533b 100644
--- a/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj
+++ b/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj
@@ -1,17 +1,11 @@
 
 
-  
-    netstandard2.0
-    8
-    1.0.0-alpha006
-    Synercoding
-    Contains classes which makes it easy to quickly create a pdf file
-    Started using Synercoding.Primitives & updated SixLabors.ImageSharp.
-    https://github.com/synercoder/FileFormats.Pdf
-    MIT
-    https://github.com/synercoder/FileFormats.Pdf
-  
-
+  
+  
+  
+    
+  
+  
   
     
     
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
index df4a997..84e541b 100644
--- a/tests/Directory.Build.props
+++ b/tests/Directory.Build.props
@@ -15,7 +15,6 @@
 
   
     netcoreapp3.1
-    8.0
     false
   
 

From 606ad7dc2e63539ecfa60dea3c490c1c248781ab Mon Sep 17 00:00:00 2001
From: Gerard Gunnewijk 
Date: Wed, 8 Jul 2020 12:17:11 +0200
Subject: [PATCH 5/7] Fixed build error

---
 src/Synercoding.FileFormats.Pdf/PdfWriter.cs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Synercoding.FileFormats.Pdf/PdfWriter.cs b/src/Synercoding.FileFormats.Pdf/PdfWriter.cs
index 0c3b883..0b8425e 100644
--- a/src/Synercoding.FileFormats.Pdf/PdfWriter.cs
+++ b/src/Synercoding.FileFormats.Pdf/PdfWriter.cs
@@ -4,6 +4,7 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Reflection;
 
 namespace Synercoding.FileFormats.Pdf
 {
@@ -38,7 +39,7 @@ public PdfWriter(Stream stream)
         public PdfWriter(Stream stream, bool ownsStream)
         {
             _stream = stream;
-            (new Header()).WriteToStream(stream);
+            new Header().WriteToStream(stream);
 
             _pageTreeNode = _tableBuilder.ReserveId();
             _catalog = _tableBuilder.ReserveId();
@@ -52,7 +53,7 @@ public PdfWriter(Stream stream, bool ownsStream)
         /// 
         public DocumentInformation DocumentInformation { get; } = new DocumentInformation()
         {
-            Producer = $"Synercoding.FileFormats.Pdf {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}",
+            Producer = $"Synercoding.FileFormats.Pdf {typeof(PdfWriter).GetTypeInfo().Assembly.GetName().Version}",
             CreationDate = DateTime.Now
         };
 

From 360a04522326c6e6a116a787e965133333d9d2bb Mon Sep 17 00:00:00 2001
From: Gerard Gunnewijk 
Date: Wed, 8 Jul 2020 12:17:28 +0200
Subject: [PATCH 6/7] Simplified jpg copy in proj

---
 .../Synercoding.FileFormats.Pdf.ConsoleTester.csproj  | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Synercoding.FileFormats.Pdf.ConsoleTester.csproj b/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Synercoding.FileFormats.Pdf.ConsoleTester.csproj
index fdb4b0c..a0af5eb 100644
--- a/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Synercoding.FileFormats.Pdf.ConsoleTester.csproj
+++ b/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Synercoding.FileFormats.Pdf.ConsoleTester.csproj
@@ -10,16 +10,7 @@
   
 
   
-    
-      PreserveNewest
-    
-    
-      PreserveNewest
-    
-    
-      PreserveNewest
-    
-    
+    
       PreserveNewest
     
   

From 202927a588d824cc5d857ab62131f564b316a892 Mon Sep 17 00:00:00 2001
From: Gerard Gunnewijk 
Date: Wed, 8 Jul 2020 12:17:39 +0200
Subject: [PATCH 7/7] Added github workflow

---
 .github/workflows/dotnet-core.yml | 93 +++++++++++++++++++++++++++++++
 Synercoding.FileFormats.Pdf.sln   |  9 +++
 2 files changed, 102 insertions(+)
 create mode 100644 .github/workflows/dotnet-core.yml

diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml
new file mode 100644
index 0000000..46cef0d
--- /dev/null
+++ b/.github/workflows/dotnet-core.yml
@@ -0,0 +1,93 @@
+name: .NET Core
+on:
+  push:
+    branches:
+      - develop
+  pull_request:
+  release:
+    types:
+      - published
+env:
+  # Stop wasting time caching packages
+  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
+  # Disable sending usage data to Microsoft
+  DOTNET_CLI_TELEMETRY_OPTOUT: true
+  # Project name to pack and publish
+  PROJECT_NAME: Synercoding.FileFormats.Pdf
+  # GitHub Packages Feed settings
+  GITHUB_FEED: https://nuget.pkg.github.com/synercoder/index.json
+  GITHUB_USER: synercoder
+  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+  # Official NuGet Feed settings
+  NUGET_FEED: https://api.nuget.org/v3/index.json
+  NUGET_KEY: ${{ secrets.NUGET_KEY }}
+jobs:
+  build:
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ ubuntu-latest, windows-latest, macos-latest ]
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+      - name: Setup .NET Core
+        uses: actions/setup-dotnet@v1
+        with:
+          dotnet-version: 3.1.x
+      - name: Restore
+        run: dotnet restore
+      - name: Build
+        run: dotnet build -c Release --no-restore
+      - name: Test
+        run: dotnet test -c Release
+      - name: Pack
+        if: matrix.os == 'ubuntu-latest'
+        run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:SymbolPackageFormat=snupkg -p:PackageVersion=$GITHUB_RUN_ID src/$PROJECT_NAME/$PROJECT_NAME.*proj
+      - name: Upload Artifact
+        if: matrix.os == 'ubuntu-latest'
+        uses: actions/upload-artifact@v2
+        with:
+          name: nupkg
+          path: ./artifacts/pkg/Release/${{ env.PROJECT_NAME }}.*.nupkg
+  prerelease:
+    needs: build
+    if: github.ref == 'refs/heads/develop'
+    runs-on: ubuntu-latest
+    steps:
+      - name: Download Artifact
+        uses: actions/download-artifact@v1
+        with:
+          name: nupkg
+      - name: Push to GitHub Feed
+        run: |
+          for f in ./nupkg/*.nupkg
+          do
+            curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
+          done
+  deploy:
+    needs: build
+    if: github.event_name == 'release'
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Setup .NET Core
+        uses: actions/setup-dotnet@v1
+        with:
+          dotnet-version: 3.1.x
+      - name: Create Release NuGet package
+        run: |
+          arrTag=(${GITHUB_REF//\// })
+          VERSION="${arrTag[2]}"
+          echo Version: $VERSION
+          VERSION="${VERSION//v}"
+          echo Clean Version: $VERSION
+          dotnet pack -v normal -c Release --include-symbols --include-source -p:SymbolPackageFormat=snupkg -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.*proj
+      - name: Push to GitHub Feed
+        run: |
+          for f in ./nupkg/*.nupkg
+          do
+            curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
+          done
+      - name: Push to NuGet Feed
+        if: ${{ env.NUGET_FEED }} != ''
+        run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY
\ No newline at end of file
diff --git a/Synercoding.FileFormats.Pdf.sln b/Synercoding.FileFormats.Pdf.sln
index 63f03b2..36f8f3e 100644
--- a/Synercoding.FileFormats.Pdf.sln
+++ b/Synercoding.FileFormats.Pdf.sln
@@ -31,6 +31,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{6AAE343B-2
 		README.md = README.md
 	EndProjectSection
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{67FFC819-02FC-4D51-8D02-4588713DE0AB}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B1B3DE7C-7961-4FA6-BABD-06B3979D1ABF}"
+	ProjectSection(SolutionItems) = preProject
+		.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -55,6 +62,8 @@ Global
 		{4FA81463-B64F-40F2-A3F1-226179796E09} = {6AAE343B-2D3D-4F7F-BC6D-6481428BECB2}
 		{E11AEF6A-6977-4D76-83E2-D5BDB84F3872} = {76970674-A4D1-4439-8EA6-8832E4A24FF1}
 		{90A3DC19-7312-4649-8B1E-9455D664C074} = {BE969D07-4BE6-4293-BBC6-C496F7D4A81C}
+		{67FFC819-02FC-4D51-8D02-4588713DE0AB} = {6AAE343B-2D3D-4F7F-BC6D-6481428BECB2}
+		{B1B3DE7C-7961-4FA6-BABD-06B3979D1ABF} = {67FFC819-02FC-4D51-8D02-4588713DE0AB}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {8DB7E905-EFFC-44B7-A5B5-3CC08E3F5AD9}