Skip to content

PDF

Pre-release

PDF export is available as a pre-release in EPPlus 9. It is not yet included in any stable version of EPPlus, and the API may change before the final release.

EPPlus can save a workbook, selected worksheets or ranges directly to PDF. The layout of the PDF is controlled by the same printer settings, headers and footers that you use for printing the worksheet in Excel.

The PDF export is implemented entirely in managed .NET code. It does not depend on Excel, on native libraries such as HarfBuzz or Skia, or on any external PDF library: text layout, font handling and PDF generation are all part of EPPlus.

Fonts

The fonts used in the workbook are embedded in the PDF as subsets, so only the characters that are actually used are included and the files stay small. EPPlus needs access to the font files to do this. See Fonts for how EPPlus finds fonts, how to configure fonts, and how font fallbacks are used for characters that are missing in a font.

Quick start

var worksheet = package.Workbook.Worksheets[0];
//Print in A4, landscape.
worksheet.PrinterSettings.PaperSize = ePaperSize.A4;
worksheet.PrinterSettings.Orientation = eOrientation.Landscape;
//Save the worksheet as PDF.
worksheet.SaveAsPdf("MyWorksheet.pdf");
Dim worksheet = package.Workbook.Worksheets(0)
'Print in A4, landscape.
worksheet.PrinterSettings.PaperSize = ePaperSize.A4
worksheet.PrinterSettings.Orientation = eOrientation.Landscape
'Save the worksheet as PDF.
worksheet.SaveAsPdf("MyWorksheet.pdf")

What you can do

  • Save a whole workbook, selected worksheets, a single range or several ranges to one PDF.
  • Save to a file or a stream, synchronously or asynchronously.
  • Control the layout with the worksheet's printer settings: paper size, orientation, margins, print area, rows and columns to repeat on each page, page order, grid lines, row and column headings, comments, error display and the first page number.
  • Add headers and footers with page numbers, dates and other automatic text.

Learn more

  • Saving to PDF - All the ways to save a workbook, worksheets and ranges to PDF.
  • Page setup - The printer settings used by the PDF export, and headers and footers.
  • Fonts - How fonts are found, configured and embedded.

Not yet supported

Some Excel features are not yet included in the PDF export, for example charts, shapes, form controls and pivot tables. Support for more features will be added in future versions. See our issue tracker for the planned features.

See also