add method to retrieve any embedded files

This commit is contained in:
Eliot Jones
2019-12-21 16:16:36 +00:00
parent 4d697e3669
commit e984180b3d
8 changed files with 271 additions and 40 deletions

View File

@@ -0,0 +1,38 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using Xunit;
public class EmbeddedFileAttachmentTests
{
[Fact]
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);
}
}
}
[Fact]
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);
}
}
}
}

View File

@@ -58,6 +58,7 @@
"UglyToad.PdfPig.AcroForms.Fields.AcroSignatureField",
"UglyToad.PdfPig.AcroForms.Fields.AcroTextField",
"UglyToad.PdfPig.AcroForms.Fields.AcroTextFieldFlags",
"UglyToad.PdfPig.AdvancedPdfDocumentAccess",
"UglyToad.PdfPig.Annotations.Annotation",
"UglyToad.PdfPig.Annotations.AnnotationBorder",
"UglyToad.PdfPig.Annotations.AnnotationFlags",
@@ -65,6 +66,7 @@
"UglyToad.PdfPig.Content.Catalog",
"UglyToad.PdfPig.Content.CropBox",
"UglyToad.PdfPig.Content.DocumentInformation",
"UglyToad.PdfPig.Content.EmbeddedFile",
"UglyToad.PdfPig.Content.Hyperlink",
"UglyToad.PdfPig.Content.InlineImage",
"UglyToad.PdfPig.Content.IPdfImage",