Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDFSharp Fixes #39

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
50 changes: 50 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- Release

pool:
vmImage: 'windows-latest'

variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'

- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'

- task: NuGetCommand@2
inputs:
command: 'pack'
packagesToPack: '**/*.csproj'
versioningScheme: 'byPrereleaseNumber'
majorVersion: '1'
minorVersion: '0'
patchVersion: '0'

- task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'b23e5b36-79b9-4a22-a765-20dec00e216d'
22 changes: 22 additions & 0 deletions src/PdfSharp-gdi/PdfSharp-gdi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@
<DebugType>none</DebugType>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;GDI;UseGdiObjects</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<FileAlignment>4096</FileAlignment>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>default</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;GDI;UseGdiObjects</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<DocumentationFile>bin\Release\PdfSharp-gdi.xml</DocumentationFile>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<FileAlignment>4096</FileAlignment>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Name>System</Name>
Expand Down
33 changes: 32 additions & 1 deletion src/PdfSharp/Pdf.Advanced/PdfTrailer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public PdfTrailer(PdfCrossReferenceStream trailer)
if (id != null)
Elements.SetValue(Keys.ID, id);
}

public int Size
{
get { return Elements.GetInteger(Keys.Size); }
Expand Down Expand Up @@ -218,6 +218,37 @@ internal void Finish()
_document._irefTable.IsUnderConstruction = false;
}

/// <summary>
/// Constructs the PdfTrailer from a document.
/// </summary>
/// <param name="parser">the parser used to read the file.</param>
internal void ConstructFromDocument(Parser parser)
{
// TODO - May need to also search for encryption related trailer info
PdfCrossReferenceTable xrefTable = _document._irefTable;
Elements.SetInteger(Keys.Size, xrefTable.ObjectTable.Count);

// find the root.
PdfDictionary rootToUse = null;
foreach (var reference in xrefTable.AllReferences)
{
PdfObject obj = parser.ReadObject(null, reference.ObjectID, false, false);
if (obj is PdfDictionary dObj)
{
if (dObj.Elements[PdfCatalog.Keys.Type] as PdfName == "/Catalog")
{
if (rootToUse == null)
rootToUse = dObj;
else if (dObj.ObjectID.GenerationNumber > rootToUse.ObjectID.GenerationNumber)
rootToUse = dObj;
}
}
}

if (rootToUse != null)
Elements.SetReference(Keys.Root, rootToUse);
}

/// <summary>
/// Predefined keys of this dictionary.
/// </summary>
Expand Down
Loading