mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-21 04:17:57 +08:00
add method to retrieve any embedded files
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
@@ -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",
|
||||
|
Reference in New Issue
Block a user