#57 add access to document metadata and expose wrapper type

This commit is contained in:
Eliot Jones
2019-08-11 12:41:51 +01:00
parent 2d6e49426a
commit 0349bedd3e
8 changed files with 120 additions and 7 deletions

View File

@@ -20,12 +20,11 @@
Assert.Contains("catus", page.Text);
}
}
[Fact]
public void CanGetAnnotations()
{
using (var document = PdfDocument.Open(GetFilename(), new ParsingOptions { UseLenientParsing = false }))
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
{
var page = document.GetPage(1);

View File

@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using PdfPig.Util;
using Xunit;
public class LaTexTests
@@ -16,7 +17,7 @@
[Fact]
public void CanReadContent()
{
using (var document = PdfDocument.Open(GetFilename()))
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
{
var page = document.GetPage(1);
@@ -125,6 +126,25 @@ used per estimate, we introduce a “complement class” Naive Bayes is often us
}
}
}
[Fact]
public void CanGetMetadata()
{
using (var document = PdfDocument.Open(GetFilename(), ParsingOptions.LenientParsingOff))
{
var hasMetadata = document.TryGetXmpMetadata(out var metadata);
Assert.True(hasMetadata);
var xDocument = metadata.GetXDocument();
Assert.NotNull(xDocument);
var text = OtherEncodings.BytesAsLatin1String(metadata.GetXmlBytes().ToArray());
Assert.StartsWith("<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'", text);
}
}
private static IReadOnlyList<AssertablePositionData> GetPdfBoxPositionData()
{