mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 19:05:01 +08:00
#127 add basic pdf/a-1b level compliance to the document builder
adds color profiles/output intents and an xmp metadata stream to the document in order to be compliant with pdf/a-1b (basic). this compliance level is toggled on the builder since it will generate larger files and set to 'off/none' by default. pdf/a documents are also not able to use standard fonts so using a font when the compliance level is not none will throw.
This commit is contained in:
@@ -195,6 +195,7 @@
|
||||
"UglyToad.PdfPig.Util.Adler32Checksum",
|
||||
"UglyToad.PdfPig.Util.IWordExtractor",
|
||||
"UglyToad.PdfPig.Util.DefaultWordExtractor",
|
||||
"UglyToad.PdfPig.Writer.PdfAStandard",
|
||||
"UglyToad.PdfPig.Writer.PdfDocumentBuilder",
|
||||
"UglyToad.PdfPig.Writer.PdfMerger",
|
||||
"UglyToad.PdfPig.Writer.PdfPageBuilder",
|
||||
|
@@ -494,6 +494,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanGeneratePdfA1BFile()
|
||||
{
|
||||
var builder = new PdfDocumentBuilder
|
||||
{
|
||||
ArchiveStandard = PdfAStandard.A1B
|
||||
};
|
||||
|
||||
var page = builder.AddPage(PageSize.A4);
|
||||
|
||||
var font = builder.AddTrueTypeFont(TrueTypeTestHelper.GetFileBytes("Roboto-Regular.ttf"));
|
||||
|
||||
page.AddText("Howdy!", 12, new PdfPoint(25, 670), font);
|
||||
|
||||
var bytes = builder.Build();
|
||||
|
||||
WriteFile(nameof(CanGeneratePdfA1BFile), bytes);
|
||||
|
||||
using (var pdf = PdfDocument.Open(bytes, ParsingOptions.LenientParsingOff))
|
||||
{
|
||||
Assert.Equal(1, pdf.NumberOfPages);
|
||||
|
||||
Assert.True(pdf.TryGetXmpMetadata(out var xmp));
|
||||
|
||||
Assert.NotNull(xmp.GetXDocument());
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteFile(string name, byte[] bytes)
|
||||
{
|
||||
try
|
||||
|
Reference in New Issue
Block a user