Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 20 additions & 12 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,33 @@
<BaseArtifactsPathSuffix>$(SynercodingProjectCategory)/$(MSBuildProjectName)</BaseArtifactsPathSuffix>
<BaseIntermediateOutputPath>$(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/</BaseIntermediateOutputPath>
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath>
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(BaseArtifactsPathSuffix)/$(Configuration)/</PackageOutputPath>
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(Configuration)/</PackageOutputPath>
</PropertyGroup>

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>portable</DebugType>
<DebugType Condition="'$(codecov)' != ''">full</DebugType>
<Nullable>enable</Nullable>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>false</SignAssembly>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Features>strict</Features>
</PropertyGroup>

<PropertyGroup>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<PropertyGroup>
<Authors>Gerard Gunnewijk</Authors>
<Company>Synercoding</Company>
<Product>Synercoding.FileFormats.Pdf</Product>
<Copyright>Copyright © $(Company)</Copyright>
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>0.0.1</VersionPrefix>
<VersionPrefix Condition="'$(packageversion)' != ''">$(PackageVersion)</VersionPrefix>
<VersionSuffix></VersionSuffix>
</PropertyGroup>

<PropertyGroup>
<NeutralLanguage>en</NeutralLanguage>
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/synercoder/FileFormats.Pdf/</RepositoryUrl>
<RestoreSources>
https://api.nuget.org/v3/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
Expand All @@ -47,6 +42,19 @@

<PropertyGroup>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Features>strict</Features>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
</PropertyGroup>

</Project>
7 changes: 0 additions & 7 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,4 @@
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Update="Aspose.PDF" Version="20.1.0" />
<PackageReference Update="iTextSharp" Version="5.5.13.1" NoWarn="NU1701" />
<PackageReference Update="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0007" />
<PackageReference Update="xunit.assert" Version="2.4.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ The sample project called *Synercoding.FileFormats.Pdf.ConsoleTester* uses multi
<pre><code>using (var fs = File.OpenWrite(fileName))
using (var writer = new PdfWriter(fs))
{
double _mmToPts(double mm) => mm / 25.4d * 72;

writer
.AddPage(page =&gt;
{
Expand Down
9 changes: 9 additions & 0 deletions Synercoding.FileFormats.Pdf.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@
</ItemGroup>

<ItemGroup>
<None Update="Pexels_com\4k-wallpaper-blur-bokeh-1484253.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Pexels_com\adult-blue-blue-eyes-865711.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Pexels_com\android-wallpaper-art-backlit-1114897.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Pexels_com\arid-barren-desert-1975514.jpg">
<None Update="Pexels_com\*.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project>

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.6</TargetFrameworks>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects>
<SynercodingProjectCategory>src</SynercodingProjectCategory>
</PropertyGroup>
Expand All @@ -15,9 +16,5 @@
<PropertyGroup>
<WarningsNotAsErrors>CS1591</WarningsNotAsErrors>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
32 changes: 0 additions & 32 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,6 @@

<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" />

<PropertyGroup>
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
</PropertyGroup>

<ItemDefinitionGroup>
<InternalsVisibleTo>
<Visible>false</Visible>
</InternalsVisibleTo>
</ItemDefinitionGroup>

<Target Name="GenerateInternalsVisibleTo"
BeforeTargets="CoreCompile"
DependsOnTargets="PrepareForBuild;CoreGenerateInternalsVisibleTo"
Condition="'@(InternalsVisibleTo)' != ''" />

<Target Name="CoreGenerateInternalsVisibleTo"
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
Inputs="$(MSBuildAllProjects)"
Outputs="$(GeneratedInternalsVisibleToFile)">
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)" Condition="'%(InternalsVisibleTo.PublicKey)' == ''">
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
</CreateItem>
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.PublicKey)" Condition="'%(InternalsVisibleTo.PublicKey)' != ''">
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
</CreateItem>

<WriteCodeFragment AssemblyAttributes="@(InternalsVisibleToAttribute)" Language="$(Language)" OutputFile="$(GeneratedInternalsVisibleToFile)">
<Output TaskParameter="OutputFile" ItemName="Compile" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
</Target>

<!-- Empty target so that `dotnet test` will work on the solution -->
<!-- https://github.com/Microsoft/vstest/issues/411 -->
<Target Name="VSTest" />
Expand Down
16 changes: 16 additions & 0 deletions src/Synercoding.FileFormats.Pdf/PackageDetails.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<PackageTags>PDF</PackageTags>
<Product>Synercoding.FileFormats.Pdf</Product>
<Title>Synercoding.FileFormats.Pdf</Title>
<Description>Contains classes which makes it easy to quickly create a pdf file.</Description>
<PackageReleaseNotes>Started using Synercoding.Primitives &amp; updated SixLabors.ImageSharp.</PackageReleaseNotes>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@

namespace Synercoding.FileFormats.Pdf.PdfInternals.Objects
{
/// <summary>
/// Interface representing a pdf object
/// </summary>
public interface IPdfObject : IStreamWriteable, IDisposable
{
/// <summary>
/// A pdf reference object that can be used to reference to this object
/// </summary>
PdfReference Reference { get; }
/// <summary>
/// Indicator to check whether this object has been written to the PDF stream
/// </summary>
bool IsWritten { get; }
}
}
7 changes: 7 additions & 0 deletions src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace Synercoding.FileFormats.Pdf.PdfInternals.Objects
{
/// <summary>
/// A class representing an image
/// </summary>
public class Image : IPdfObject, IDisposable
{
private readonly SixLabors.ImageSharp.Image _image;
Expand All @@ -16,10 +19,13 @@ internal Image(PdfReference id, SixLabors.ImageSharp.Image image)
_image = image;
}

/// <inheritdoc />
public PdfReference Reference { get; private set; }

/// <inheritdoc />
public bool IsWritten { get; private set; }

/// <inheritdoc />
public void Dispose()
{
if(!_disposed)
Expand All @@ -29,6 +35,7 @@ public void Dispose()
}
}

/// <inheritdoc />
public uint WriteToStream(Stream stream)
{
if(_disposed)
Expand Down
20 changes: 19 additions & 1 deletion src/Synercoding.FileFormats.Pdf/PdfInternals/PdfReference.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
namespace Synercoding.FileFormats.Pdf.PdfInternals
{
public struct PdfReference
/// <summary>
/// A struct representing a reference
/// </summary>
public readonly struct PdfReference
{
/// <summary>
/// Constructor for <see cref="PdfReference"/> that uses generation 0
/// </summary>
/// <param name="objectId">The id of the reference</param>
public PdfReference(int objectId)
: this(objectId, 0)
{ }

/// <summary>
/// Constructor for <see cref="PdfReference"/>
/// </summary>
/// <param name="objectId">The id of the reference</param>
/// <param name="generation">The generation of the reference</param>
public PdfReference(int objectId, int generation)
{
ObjectId = objectId;
Generation = generation;
}

/// <summary>
/// The object id of this reference
/// </summary>
public int ObjectId { get; }
/// <summary>
/// The generation of this reference
/// </summary>
public int Generation { get; }
}
}
Loading