We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf attachment extraction

Hello,

i'm using Aspose.Pdf.Net version 6.0.0 and Microsoft NET 3.5 SP1.

I need to extract a xml attatchment from a in memory pdf file containing other attatchments too.

I tried to use this code:

byte[] pdfDocument = pdfConsegna.PdfContent;

PdfExtractor extractor = new PdfExtractor();

using (MemoryStream pdfMs = new MemoryStream(pdfDocument))

{

extractor.BindPdf(pdfMs);


// estract xml byte[] by filename

IList attachmentNames = extractor.GetAttachNames();

foreach (string attName in attachmentNames)
{
// check if fileName is a xml

if (Path.GetExtension(attName).ToLowerInvariant() == ".xml")
{

// extract attachment by fileName
extractor.ExtractAttachment(attName);

MemoryStream[] xmlMSs = extractor.GetAttachment(); // this does'n work, xmlMSs is null

if (xmlMSs != null)
{
MemoryStream xmlMS = xmlMSs[0];

// assign values

xmlDocument.FileName = attName;

xmlMS.Close();

xmlDocument.FileContent = xmlMS.ToArray();

break;
}
}
}
}

but the code does'nt work because GetAttachment() funtion returns null;

Can you help me?

How can i extract a specific attachment?

Thank you very much.

Hi,

Thanks for using our products.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as <span style=“font-family:“Arial”,“sans-serif””>PDFNEWNET-29618. We will
investigate this issue in details and will keep you updated on the status of a
correction.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

We
apologize for your inconvenience.