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.