#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:
Eliot Jones
2020-03-29 16:43:52 +01:00
parent 7d52bc8be4
commit 5f45ee53bd
9 changed files with 378 additions and 6 deletions

View File

@@ -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",

View File

@@ -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