←Select platform

IsPortfolio Property

Summary

Indicates whether this PDF document is a portfolio.

Syntax
C#
C++/CLI
Java
Python
public bool IsPortfolio {get;} 
public boolean isPortfolio(); 
public:  
   property bool IsPortfolio 
   { 
      bool get() 
   } 
IsPortfolio # get  (PDFDocument) 

Property Value

true if the PDF document is portfolio; otherwise, false.

Remarks

A PDF file can be created as a portfolio, which contains multiple files assembled into an integrated unit. In these types of documents, the file contains a single generic help page with text such as "For the best experience, open this PDF portfolio in a compatible viewer". It can also contain any number of attachments, as well as a schema to control how to view the document.

The value of IsPortfolio will be true if the file is a PDF portfolio. It is up to the application to determine further handling of the file.

IsPortfolio and HasEmbeddedFiles are automatically populated by the PDFDocument constructor.

Calling ParseDocumentStructure with the PDFParseDocumentStructureOptions.EmbeddedFiles flag to parse the schema and embedded files (attachments) found in the PDF document and populate the EmbeddedFiles and EmbeddedFilesSchemas collections.

Generally, the PDF document is considered to be a portfolio when it has one or more embedded file schemas. In this case, the Pages collection will have a single page containing generic help instructions and is used if the application does not support PDF schemas. Otherwise, the application can read the EmbeddedFilesSchemas collection and construct the necessary UI to view the embedded files. Pages should not be used.

A PDF document with one or more embedded files but no schema will have the value of IsPortfolio set to false and EmbeddedFilesSchemas will be empty. Therefore, this is a normal PDF with attachments. Pages will contain one or more pages of the actual document that can and should be viewed normally. The attachments included in EmbeddedFiles can be processed further if desired (for instance, in a separate attachments UI interface).

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
using Leadtools.WinForms; 
 
 
public static void ExtractEmbeddedFiles(string inputFileName, string outputDir) 
{ 
   // Load the source document 
   PDFDocument pdfDocument = new PDFDocument(inputFileName); 
   if (!pdfDocument.HasEmbeddedFiles) 
   { 
      Console.WriteLine("PDF does not have embedded files"); 
      // No embedded files 
      pdfDocument.Dispose(); 
      return; 
   } 
 
   // Read the attachments 
   pdfDocument.ParseDocumentStructure(PDFParseDocumentStructureOptions.EmbeddedFiles); 
 
   if (!Directory.Exists(outputDir)) 
      Directory.CreateDirectory(outputDir); 
 
   foreach (PDFEmbeddedFile embeddedFile in pdfDocument.EmbeddedFiles) 
   { 
      // Show this file information 
      Console.WriteLine($"Number:{embeddedFile.FileNumber}"); 
      Console.WriteLine($"  FileName:{embeddedFile.FileName}"); 
      Console.WriteLine($"  FileSize:{embeddedFile.FileSize}"); 
      Console.WriteLine($"  Description:{embeddedFile.Description}"); 
      Console.WriteLine($"  Created:{embeddedFile.Created}"); 
      Console.WriteLine($"  Modified:{embeddedFile.Modified}"); 
 
      // Extract this attachment to the output directory 
      // Note: FileName of an embedded file is not guaranteed to be unique, therefore, we will append 
      // the file number which is unique to the output name 
      string outputFileName = $"{embeddedFile.FileNumber}-{embeddedFile.FileName}"; 
      Console.WriteLine($"  Extracting to {outputFileName}"); 
      outputFileName = Path.Combine(outputDir, outputFileName); 
      PDFFile.ExtractEmbeddedFile(inputFileName, pdfDocument.Password, embeddedFile.FileNumber, outputFileName); 
   } 
 
   pdfDocument.Dispose(); 
} 
Requirements

Target Platforms

Help Version 22.0.2023.7.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.