mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-07-16 16:22:00 +08:00
add pdf/a2-a support
This commit is contained in:
parent
ab94746252
commit
635ae13a77
@ -494,40 +494,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanGeneratePdfA1BFile()
|
||||
[Theory]
|
||||
[InlineData(PdfAStandard.A1B)]
|
||||
[InlineData(PdfAStandard.A1A)]
|
||||
[InlineData(PdfAStandard.A2B)]
|
||||
[InlineData(PdfAStandard.A2A)]
|
||||
public void CanGeneratePdfAFile(PdfAStandard standard)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanGeneratePdfA1AFile()
|
||||
{
|
||||
var builder = new PdfDocumentBuilder
|
||||
{
|
||||
ArchiveStandard = PdfAStandard.A1A
|
||||
ArchiveStandard = standard
|
||||
};
|
||||
|
||||
var page = builder.AddPage(PageSize.A4);
|
||||
@ -537,39 +513,11 @@
|
||||
|
||||
var font = builder.AddTrueTypeFont(TrueTypeTestHelper.GetFileBytes("Roboto-Regular.ttf"));
|
||||
|
||||
page.AddText("Howdy PDF/A-1A!", 10, new PdfPoint(25, 700), font);
|
||||
page.AddText($"Howdy PDF/{standard}!", 10, new PdfPoint(25, 700), font);
|
||||
|
||||
var bytes = builder.Build();
|
||||
|
||||
WriteFile(nameof(CanGeneratePdfA1AFile), 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());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanGeneratePdfA2BFile()
|
||||
{
|
||||
var builder = new PdfDocumentBuilder
|
||||
{
|
||||
ArchiveStandard = PdfAStandard.A2B
|
||||
};
|
||||
|
||||
var page = builder.AddPage(PageSize.A4);
|
||||
|
||||
var font = builder.AddTrueTypeFont(TrueTypeTestHelper.GetFileBytes("Roboto-Regular.ttf"));
|
||||
|
||||
page.AddText("Howdy PDF/A-2B and welcome!", 10, new PdfPoint(25, 700), font);
|
||||
|
||||
var bytes = builder.Build();
|
||||
|
||||
WriteFile(nameof(CanGeneratePdfA2BFile), bytes);
|
||||
WriteFile(nameof(CanGeneratePdfAFile) + standard, bytes);
|
||||
|
||||
using (var pdf = PdfDocument.Open(bytes, ParsingOptions.LenientParsingOff))
|
||||
{
|
||||
|
@ -20,6 +20,10 @@
|
||||
/// <summary>
|
||||
/// Compliance with PDF/A2-B. Level B (basic) conformance are standards necessary for the reliable reproduction of a document's visual appearance.
|
||||
/// </summary>
|
||||
A2B = 3
|
||||
A2B = 3,
|
||||
/// <summary>
|
||||
/// Compliance with PDF/A2-A. Level A (accessible) conformance are PDF/A2-B standards in addition to features intended to improve a document's accessibility.
|
||||
/// </summary>
|
||||
A2A = 4
|
||||
}
|
||||
}
|
@ -352,6 +352,9 @@ namespace UglyToad.PdfPig.Writer
|
||||
break;
|
||||
case PdfAStandard.A2B:
|
||||
break;
|
||||
case PdfAStandard.A2A:
|
||||
PdfA1ARuleBuilder.Obey(catalogDictionary);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,10 @@ namespace UglyToad.PdfPig.Writer.Xmp
|
||||
part = 2;
|
||||
conformance = "B";
|
||||
break;
|
||||
case PdfAStandard.A2A:
|
||||
part = 2;
|
||||
conformance = "A";
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(standard), standard, null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user