Metadata of PDFs embedded in a portfolio

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v9)  /  Metadata of PDFs embedded in a portfolio

DynamicPDF CoreSuite for .NET (v9) Forum

The ability to extract  PDFs from a portfolio is a most welcome addition to DynamicPDF Merger. However, the Feature would be more useful if the API would provide a direct access to the metadata associated with the files embedded in the portfolio. A very common use case are the portfolios generated through the Outlook Plugin, which produces 17 columns of email metadata that are most valuable in the extraction process.
Posted by a ceTe Software moderator
Hello,

You can retrieve the xmp metadata from the PDF files embedded in the portfolios using DynamicPDF Merger for .NET product. You will need to load the portfolio using the PdfDocument class. Get the embedded files using Attachments method of PdfDocument object. You will need to loop through the attachments and get the PDF byte array and create a PdfDocument object. Then you can read the  xmp metadata into string using XmpMetadata property of the PdfDocument object. Below is the code sample.

            PdfDocument pdf = new PdfDocument(@"Path for portfolio PDF");
            if (pdf.CollectionType == CollectionType.AdobePortfolio)
            {
                Attachment[] pdfFiles = pdf.Attachments();
                for (int i = 0; i < pdfFiles.Length; i++)
                {
                    if (pdfFiles[i].Filename.EndsWith(".pdf"))
                    {
                        PdfDocument EmbeddedPdf = new PdfDocument(pdfFiles[i].GetData());
                        string xmpString = EmbeddedPdf.XmpMetadata;                        
                    }
                 }
             }         

Thanks,
ceTe Software Support Team.
Thank you - this is pretty much what I ended up doing, in despair. I was hoping for a more immediate approach, avoiding the full extraction of all those embedded PDFs. Never mind.
Incidentally, CollectionType always seems to return 0, even with portfolios.
Posted by a ceTe Software moderator
Hello,

We have tested several portfolios and the CollectionType property is returning the correct value. Please email the portfolio PDF that returns incorrect CollectionType to support@cete.com so we can look into it further.

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 4:30 AM.