Create a PDF Portfolio in C#

A PDF Portfolio allows us to put multiple types of files (for example, text documents, email messages, spreadsheets and PowerPoint presentations) together into a master PDF file. The files in a PDF Portfolio can retain their individual identities. We can open, read, edit, and format each component file independently of the other component files.

Spire.PDF for .NET supports creating a PDF Portfolio, adding files and folders to the PDF Portfolio. The following example demonstrates how to create a PDF Portfolio and add files to it using Spire.PDF for .NET.

using System;
using Spire.Pdf;

namespace CreatePDFPortfolio
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] files = new String[] { "Instruction.pdf", "Sales Report.docx", "Sample.xlsx" };
            //Create a PdfDocument instance
            using (PdfDocument doc = new PdfDocument())
            {
                //Create a PDF Portfolio and add files to it
                for (int i = 0; i < files.Length; i++)
                {
                    doc.Collection.AddFile(files[i]);
                    
                }
                //Save the result file
                doc.SaveToFile("PortfolioWithFiles.pdf", FileFormat.PDF);
                doc.Dispose();
            }
        }
    }
}

Create a PDF Portfolio in C#

The following example shows how to create a PDF Portfolio and add folders to it using Spire.PDF for .NET.

using System;
using Spire.Pdf;
using Spire.Pdf.Collections;

namespace CreatePDFPortfolio
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] files = new String[] { "Instruction.pdf", "Sales Report.docx", "Sample.xlsx" };
            //Create a PdfDocument instance
            using (PdfDocument doc = new PdfDocument())
            {
                //Create a PDF Portifolio, add folders to it and add files to the folders
                for (int i = 0; i < files.Length; i++)
                {                                       
                    PdfFolder folder = doc.Collection.Folders.CreateSubfolder("Folder" + i);
                    folder.AddFile(files[i]);
                }
                //Save the result file
                doc.SaveToFile("PortfolioWithFolders.pdf", FileFormat.PDF);
                doc.Dispose();
            }
        }
    }
}

Create a PDF Portfolio in C#