Click or drag to resize
Pdf Library for .NET

Pdf Portfolios

A PDF Portfolio contains multiple files assembled into an integrated PDF unit. The files in a PDF Portfolio can be in a wide range of file types created in different applications. For example, a PDF Portfolio can include text documents, e-mail messages, spreadsheets, CAD drawings, and PowerPoint presentations. The original files retain their individual identities but are assembled into one PDF Portfolio file. You can open, read, edit, and format each component file independently of the other component files in the PDF Portfolio.

PDF portfolios can be handled in .NET applications using SelectPdf with PdfPortfolioManager object. Using PdfPortfolioManager the following tasks can be performed:

Code Sample

The following sample code shows how to create a new PDF portfolio, add 3 embedded files, set the view mode and startup file and save the newly created PDF portfolio on disk.

// the test files
string filePdf = Server.MapPath("~/files/doc.pdf");
string fileHtml = Server.MapPath("~/files/document.html");
string fileImage = Server.MapPath("~/files/logo.png");

// instantiate the pdf portfolio manager
PdfPortfolioManager portfolio = new PdfPortfolioManager();

// add files to the portfolio
PdfPortfolioFile pdfFilePdf = new PdfPortfolioFile(filePdf);
pdfFilePdf.Description = "PDF document";
portfolio.Files.Add(pdfFilePdf);

PdfPortfolioFile pdfFileHtml = new PdfPortfolioFile(fileHtml);
pdfFileHtml.Description = "HTML document";
portfolio.Files.Add(pdfFileHtml);

PdfPortfolioFile pdfFileImage = new PdfPortfolioFile(fileImage);
pdfFileImage.Description = "Image file";
portfolio.Files.Add(pdfFileImage);

// set view mode
portfolio.ViewMode = PdfPortfolioViewMode.Details;

// set startup file
portfolio.StartupFileName = "logo.png";

// save pdf document
portfolio.Save("Sample.pdf");

// close pdf document
portfolio.Close();

The following sample code shows how to go through all embedded files from a PDF portfolio and export all of them to the disk:

// instantiate the pdf portfolio manager
PdfPortfolioManager portfolio = new PdfPortfolioManager();

// load existing PDF portfolio file
portfolio.Load("portfolio.pdf");

// go though the file list and export all files            
for (int i = 0; i < portfolio.Files.Count; i++)
{
    PdfPortfolioFile file = portfolio.Files[i];

    FileStream s = new FileStream("export\\" + file.Name, FileMode.Create);
    s.Write(file.Content, 0, file.Content.Length);
    s.Dispose();
}

// close pdf document
portfolio.Close();
See Also