The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

Export to PDF

  • 5 min to read

Call the RichEditDocumentServer.ExportToPdf method to export the document to the PDF format. Use the PdfExportOptions object's properties to define the required export options, as shown in the following code:

server.LoadDocument("Documents\\MovieRentals.docx", DocumentFormat.OpenXml);
//Specify export options:
PdfExportOptions options = new PdfExportOptions();
options.DocumentOptions.Author = "Mark Jones";
options.Compressed = false;
options.ImageQuality = PdfJpegImageQuality.Highest;
//Export the document to the stream: 
using (FileStream pdfFileStream = new FileStream("Document_PDF.pdf", FileMode.Create))
{
    server.ExportToPdf(pdfFileStream, options);
}
System.Diagnostics.Process.Start("Document_PDF.pdf");

Sections below provide more detailed information about the PDF export specifics.

PDF Document Versions

The PDF export engine produces PDF documents of the following versions depending on specified export options:

PDF Cross-Compatibility

PDF generation does not require installing third-party components on an end-user's machine.

  • When including Far-Eastern and Arabic fonts into PDF, make sure that the included fonts contain all necessary characters.
  • Document hyperlinks will be active in PDF only if the Create links from URLs setting is enabled in Adobe® Reader installed on the target machine.

    To access this option in the program's Edit menu, click Preferences and in the invoked dialog, switch to General.

    export_PDF

The document pages' background is filled with the color specified by the XtraReport.PageColor property. If you want to add a background image to the PDF file, set this property to Transparent.

The PDF options are provided by the PdfExportOptions class. These options can be accessed via a report's ExportOptions.Pdf property and are detailed in the following sections.

PDF/A Options

The following PDF/A specifications are supported.

  • PDF/A-1b (ISO 19005-1)
  • PDF/A-2b (ISO 19005-2:2011)
  • PDF/A-3b (ISO 19005-3:2012)

To make a document compatible with the PDF/A specification, use the following options.

If the PdfExportOptions.PdfACompatibility property is set to PdfACompatibility.None (the default value), the resulting document will conform to the ISO 32000-1:2005 standard without any restrictions.

For a code sample, refer to the following example online: How to export a report to ZUGFeRD.

For the current versions of the library, consider the following restrictions associated with PDF/A compatibility.

  • All PDF/A versions implicitly prohibit encryption.
  • All fonts that are used in PDF/A documents should be embedded.
  • The PDF/A-1b and PDF/A-2b standards do not support attachments.
  • The PDF/A-1b standard does not support transparency, and the alpha channel in images will be ignored.

To check the validity of PDF export options, use the PdfExportOptions.Validate method that returns a list of any detected inconsistencies.

Document Options

Security Options

File Size Optimization

Use the following options to vary the quality of PDF-embedded images and in this way, control the resultant file size.

To reduce the size of large documents (e.g., before sending them via e-mail), you can use the following option.

As for the embedded fonts and PDF page content, they are always compressed in the resulting PDF file.

Current Limitations

At present, the following limitations apply to PDF export:

  • Glyph Shaping does not work for non-embedded fonts.
  • Support for right-to-left languages with non-embedded fonts requires that your application runs under full trust.
  • Export of vector EMF and WMF images is not supported. The current export mechanism supports EMF+ only.
See Also