mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-18 18:27:55 +08:00
merge pull request #43 from Numpsy/test_document_information
Add a unit test for reading document information
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
namespace UglyToad.PdfPig.Tests.Integration
|
||||
{
|
||||
using System;
|
||||
using PdfPig.Tokens;
|
||||
using Xunit;
|
||||
|
||||
public class DocumentInformationTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanReadDocumentInformation()
|
||||
{
|
||||
var path = IntegrationHelpers.GetSpecificTestDocumentPath("custom-properties.pdf");
|
||||
|
||||
using (var document = PdfDocument.Open(path))
|
||||
{
|
||||
var information = document.Information;
|
||||
|
||||
Assert.Equal("Writer", information.Creator);
|
||||
Assert.Equal("MoreKeywords", information.Keywords);
|
||||
Assert.Equal("LibreOffice 6.1", information.Producer);
|
||||
Assert.Equal("TestSubject", information.Subject);
|
||||
Assert.Equal("TestTitle", information.Title);
|
||||
|
||||
var infoDictionary = information.DocumentInformationDictionary;
|
||||
|
||||
var nameToken = NameToken.Create("CustomProperty1");
|
||||
Assert.True(infoDictionary.TryGet(nameToken, out var valueToken), "first custom property must be present");
|
||||
Assert.IsType<StringToken>(valueToken);
|
||||
Assert.Equal("Property Value", ((StringToken)valueToken).Data);
|
||||
|
||||
nameToken = NameToken.Create("CustomProperty2");
|
||||
Assert.True(infoDictionary.TryGet(nameToken, out var valueToken2), "second custom property must be present");
|
||||
Assert.IsType<StringToken>(valueToken2);
|
||||
Assert.Equal("Another Property Value", ((StringToken)valueToken2).Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@@ -74,6 +74,7 @@
|
||||
<Content Include="Fonts\Type1\CMCSC10.pfa" />
|
||||
<Content Include="Fonts\Type1\Raleway-Black.pfb" />
|
||||
<Content Include="Integration\SpecificTestDocuments\invalid-xref-loop.pdf" />
|
||||
<Content Include="Integration\SpecificTestDocuments\custom-properties.pdf" />
|
||||
<Content Include="Parser\SimpleGoogleDocPageContent.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
Reference in New Issue
Block a user