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); } }
public void HasEmbeddedFiles() { var path = IntegrationHelpers.GetSpecificTestDocumentPath("embedded-file-attachment.pdf"); using (var document = PdfDocument.Open(path)) { Assert.True(document.Advanced.TryGetEmbeddedFiles(out var files)); Assert.Equal(1, files.Count); Assert.Equal(20668, files[0].Bytes.Count); } }
public void HasCorrectText() { var path = IntegrationHelpers.GetSpecificTestDocumentPath("embedded-file-attachment.pdf"); using (var document = PdfDocument.Open(path)) { for (var i = 1; i <= document.NumberOfPages; i++) { var page = document.GetPage(i); Assert.StartsWith("This is a test document. It contains a file attachment.", page.Text); } } }
public void CanOpenDocumentAndGetPage() { var path = IntegrationHelpers.GetSpecificTestDocumentPath("invalid-xref-loop.pdf"); using (var document = PdfDocument.Open(path)) { for (var i = 1; i <= document.NumberOfPages; i++) { var page = document.GetPage(i); Assert.NotNull(page.Content); } } }
private static string GetPath() => IntegrationHelpers.GetSpecificTestDocumentPath(FileName);