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
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;CA1416;NU1608;NU1109</NoWarn>
<Version>5.26.0</Version>
<Version>5.27.0</Version>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Aspose, Verify</PackageTags>
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageVersion Include="Aspose.PDF" Version="26.4.0" Pinned="true" />
<PackageVersion Include="Aspose.Slides.NET" Version="26.7.0" />
<PackageVersion Include="Aspose.Words" Version="26.7.0" />
<PackageVersion Include="DeterministicPdf" Version="1.0.1" />
<PackageVersion Include="DeterministicIoPackaging" Version="0.30.0" />
<PackageVersion Include="MarkdownSnippets.MsBuild" Version="28.4.1" />
<PackageVersion Include="Microsoft.Bcl.Memory" Version="10.0.10" />
Expand Down
1 change: 1 addition & 0 deletions src/Verify.Aspose/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
global using System.Xml.Linq;
global using Aspose.Pdf.Devices;
global using DeterministicIoPackaging;
global using DeterministicPdf;
global using VerifyTestsAspose;
1 change: 1 addition & 0 deletions src/Verify.Aspose/Verify.Aspose.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ItemGroup>
<PackageReference Include="Aspose.Pdf" />
<PackageReference Include="DeterministicIoPackaging" />
<PackageReference Include="DeterministicPdf" />
<PackageReference Include="Microsoft.Bcl.Memory" />
<PackageReference Include="Verify" />
<PackageReference Include="Aspose.Cells" />
Expand Down
35 changes: 32 additions & 3 deletions src/Verify.Aspose/VerifyAspose_Pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ static ConversionResult ConvertPdf(string? name, Document document, IReadOnlyDic
}

var (fonts, embeddedFonts) = GetPdfFonts(document);
return new(

// Built before the targets, preserving the original evaluation order: GetDocumentText below
// re-saves the document to extract its text, and the page rendering in GetPdfStreams has
// always run after that.
var snapshotInfo =
new
{
Pages = document.Pages.Count,
Expand Down Expand Up @@ -124,8 +128,33 @@ static ConversionResult ConvertPdf(string? name, Document document, IReadOnlyDic
Fonts = fonts,
EmbeddedFonts = embeddedFonts,
Text = GetDocumentText(document)
},
GetPdfStreams(name, document, settings).ToList());
};

List<Target> targets = [];
// Building the deterministic pdf is expensive, so skip it when the pdf target is excluded.
if (!settings.IsTargetExcluded("pdf"))
{
targets.Add(BuildPdfTarget(document));
}

targets.AddRange(GetPdfStreams(name, document, settings));

return new(snapshotInfo, targets);
}

// The pdf snapshot is always the full document, regardless of PagesToInclude: PagesToInclude
// only trims the rendered png pages in GetPdfStreams. Mirrors BuildXlsxTarget/BuildDocxTarget,
// which do the same for the OOXML formats via DeterministicPackage.
static Target BuildPdfTarget(Document document)
{
using var source = new MemoryStream();
document.Save(source);
var resultStream = PdfNormalizer.Normalize(source);

return new("pdf", resultStream, performConversion: false)
{
BypassComparersForSubsequentOnDifference = true
};
}

static string GetDocumentText(Document document)
Expand Down
Loading