• 24.1 (EAP/Beta)
  • DevExpress documentation only
  • All DevExpress web resources

Export to PDF

  • Mar 15, 2024
  • 12 minutes to read

Export From Preview (Visual Studio, WinForms, WPF)

You can export a report from Visual Studio Preview tab , WinForms Print Preview , and WPF Print Preview . Expand the drop-down list with export formats and select PDF File .

export pdf devexpress

Specify export options in the invoked PDF Export Options dialog and click OK .

Export From Document Viewer (Web Platforms)

You can export a report from ASP.NET Web Forms Document Viewer , ASP.NET MVC Document Viewer , and ASP.NET Core Document Viewer . Specify export options in the Export Options dialog, expand the Export To drop-down list in the toolbar, and select PDF .

export pdf devexpress

Export in Code

Use the XtraReport.ExportToPdf or XtraReport.ExportToPdfAsync methods to export a report to PDF format. Specify the path/stream to which the report should be exported as the first argument in these methods. If you specify only the path/stream, the report is exported to PDF format with the default options. To change the default options, do one of the following:

  • Create a PdfExportOptions object, specify export options for this object, then pass the object to the XtraReport.ExportToPdf or XtraReport.ExportToPdfAsync methods as the second argument.
  • Open a report in the Visual Studio Designer and change the export options in the Properties panel.

Export a Large Report

To export a large report in code, use the PdfStreamingExporter class instead of the XtraReport.ExportToPdf / XtraReport.ExportToPdfAsync method calls. You can use the PdfStreamingExporter class together with CachedReportSource (WinForms/WPF) or CachedReportSourceWeb (Web platforms).

View Example: Export a Report to PDF Format

PDF Document Versions

The PDF export engine produces the following PDF document versions:

Export Options

The following options are available in the PDF Export Dialog invoked from Visual Studio Preview tab , WinForms Print Preview , and WPF Print Preview , and in the Export Options dialog of the Document Viewer (Web platforms) .

  • Export Editing Fields To AcroForms

PDF/A Compatibility

Pdf/ua compatibility, file size optimization, password security, digital signature, document options.

The options below are available only in the Properties panel of the Report Designer (Visual Studio, WinForms, and WPF) …

export pdf devexpress

… and in the Export options dialog of the Document Viewer (Web platforms) .

Show Print Dialog On Open

  • Rasterization Resolution

The Page Range option specifies the range of pages that should be exported to a PDF file. For example, the “1,3,5-12” range exports the first, third, and all pages from the fifth to 12th.

Export Editing Fields to AcroForms

Enable the Export Editing Fields To AcroForms option to convert a report’s editing fields to interactive forms in the exported PDF file.

Watch Video: Create Accessible PDF/A-1a, PDF/A-2a, PDF/A-3a, and PDF/UA-1 Documents from DevExpress Reports

Use the Pdf/A Compatibility option to make the exported PDF file compatible with the PDF/A specification. Set the option to one of the following values:

  • PDF/A-1a (based on PDF/A-1b with conformance for accessibility based on the tagged document structure)
  • PDF/A-1b ( ISO 19005-1 )
  • PDF/A-2a (based on PDF/A-2b with conformance for accessibility based on the tagged document structure)
  • PDF/A-2b ( ISO 19005-2:2011 )
  • PDF/A-3a (based on PDF/A-3b with conformance for accessibility based on the tagged document structure)
  • PDF/A-3b ( ISO 19005-3:2012 )

When the option is set to the default value ( None ), the exported PDF file conforms to ISO 32000-1:2005 .

You can use the screen reader to vocalize the content of a PDF document’s elements. For tagged PDF documents (PDF/A-1a, PDF/A-2a, and PDF/A-3a), you can specify custom text that the screen reader can vocalize instead of an element’s default content. Refer to the following topic for more information: AccessibleDescription .

When you create a PDF/A compatible document, you can add additional metadata to the exported PDF file. Refer to the code example below that exports a simple report to a PDF/A-3b ( ISO 19005-3 ) file. The exported file meets the ZUGFeRD specification used for electronic invoices in Germany.

View Example

Limitations

If a report contains the XRPdfContent control, you cannot export this report to PDF with the PDF/A option enabled. If you enable this option, the exception is raised when you export the report to PDF.

The following PDF export options are not supported for PDF/A compatible documents:

Never Embedded Fonts

  • Attachments (not supported only for PDF/A-1a , PDF/A-1b , PDF/A-2a , and PDF/A-2b )
  • Export Editing Fields to AcroForms (not supported only for PDF/A-1a and PDF/A-1b )

If you export a report to a PDF/A compatible document in code, use the Validate method to check whether the specified export options can be used for PDF/A compatible documents.

Use the Pdf/UA Compatibility option to make the exported PDF file compatible with the PDF/UA specification. If you set this option to PDF/UA1 , the resulting file meets the ISO 14289 standard that defines the structure and tagged PDF features for use in assistive technologies.

You can specify the role of a UI element in the exported document for the screen reader. You can define the role of the following controls:

  • XRTableRow.AccessibleRole
  • XRTable.AccessibleRole
  • XRLabel.AccessibleRole
  • XRTableCell.AccessibleRole

You can use the screen reader to vocalize the content of a PDF document’s elements. For a tagged PDF document, which conforms to the PDF/UA standard, you can specify custom text that the screen reader can vocalize instead of an element’s default content. Refer to the AccessibleDescription topic for more details.

A series of localization strings in the PreviewStringId enumeration with the Accessibility prefix allow you to localize the report control name for the screen reader.

  • The Never Embedded Fonts export option is not supported for PDF/UA compatible documents.
  • If a report contains the XRPdfContent control, you cannot export this report to PDF with the PDF/UA option enabled. If you enable this option, the exception is raised when you export the report to PDF.
  • If a report contains editing fields or the XRPdfSignature control, the PDF document generated from this report does not comply with the PDF/UA requirements.

Use the options below to decrease the size of the exported PDF file.

Image Quality

Enable the Convert Images To JPEG option to convert all images to JPEG. An image is converted to JPEG if the size of a JPEG image is smaller than the original image size. When the option is enabled, you can use the Image Quality option to change the image quality and the Rasterization Resolution option to specify the image resolution.

Use the Do Not Embed These Fonts ( Never Embedded Fonts in the Document Viewer ) to specify fonts that should not be embedded to the exported PDF file.

Use the Password Security options to specify an open password and permissions to copy , print , and use screen readers for the exported PDF file. To encrypt the content of the PDF file, set encryption level to one of the following algorithms:

  • 128-bit AES (Advanced Encryption Standard) - the default algorithm;
  • 256-bit AES (Advanced Encryption Standard);
  • 128-bit ARC4 (Alleged Rivest Cipher 4 ).

PDF passwords are stored in report definitions as plain text. Ensure that only trusted parties have access to report definition files.

You can sign a report with an X.509 certificate when you export it to PDF. The specified signature information is saved to the document’s PDF Signature Options .

Run Demo: Online Run Demo: Desktop

The XRPdfSignature control can visualize the document’s signature in the exported PDF file.

View Example: How to use the digital signature options when exporting a report to PDF

To sign the exported PDF document in the Web Document Viewer, use one of the following options:

The following example shows how to sign a document exported to PDF:

View Example: How to Sign the Exported PDF Document

Use Document Options to specify information that should be embedded as Document Properties in the exported PDF file.

Enable the Show Print Dialog On Open option to invoke a print dialog when users open the exported PDF file. Do not use this option in web applications because most modern browsers disable scripts in PDF.

Review the following web application examples that export a report to PDF and print it in a browser without a preview:

  • How to print/export XtraReport in an ASP.NET WebForms application without showing a report preview
  • How to print/export XtraReport in an ASP.NET MVC application without showing a report preview
  • How to Print and Export a Report in the ASP.NET Core Application without the Document Viewer
  • How to print and export DevExpress reports without previewing them on a web page in an Angular application with an ASP.NET Core backend
  • How to Print and Export a Report in a React Application without Displaying the Report
  • EMF and WMF images cannot be exported. Only EMF+ is available.
  • The PDF/A-1b standard does not support transparent images. In PDF/A-1b compatible files, an alpha channel in images is ignored.
  • The background of the exported PDF file is filled with the color assigned to the PageColor property. Set this property to Transparent if you add a background image to the exported PDF file.

In Adobe Reader, hyperlinks for the exported PDF file work only if the Create links from URLs option is enabled.

export_PDF

  • OpenType Variable fonts (TrueType and CFF flavored), and OpenType SVG fonts are not supported.
  • DevExpress’s wordwrap algorithm does not support additional characters such as soft and hard hyphens, zero-width spaces, and word joiners.

The Exported PDF File Differs From the Print Preview: Troubleshooting

A reporting application uses the Windows GDI+ API to draw the Print Preview . The PDF export engine utilizes another API to generate a PDF file from a report. Since the two APIs use different algorithms to process characters, the exported PDF file might differ from the report’s Print Preview .

Missed Characters in the Exported PDF File

If a font you use in a report does not contain a glyph for a character, this character may not be displayed in PDF file. Make sure that the system contains a font with missing glyphs to avoid this issue. Refer to the following article for information no how to install fonts to different systems: Use Custom Fonts in Reporting .

Inconsistent Line Breaks

The GDI+ API and the reporting PDF export engine use different algorithms to process line breaks. If you use Chinese, Japanese, or Korean characters in a report, line breaks might be displayed differently in the Print Preview and exported PDF file.

To resolve this issue, set the UseGdiPlusLineBreakAlgorithm property to true to use the GDI+ line break algorithm when a report is exported to PDF.

Post-Process PDF Files

You can post-process the resulting PDF files with the help of a dedicated DevExpress library: PDF Document API . This product helps you edit, merge, split, password-protect, and digitally sign PDF files.

You may also use PDF Document API to generate PDF documents from scratch. If that code-only approach suits your requirements, you don’t need to construct a report in the designer at all.

PDF Document API works in desktop and web applications that target a variety of platforms (Windows Forms, WPF, ASP.NET Web Forms, ASP.NET MVC, ASP.NET Core, Blazor, MAUI) and operating systems (Windows, Linux, macOS).

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use the library in production code.

If you haven’t yet done so, download our fully-functional 30-day trial version to try out DevExpress controls and libraries in your projects:

Download: Free 30-Day Trial

If you have any questions, submit a ticket to our Support Center .

PDF Export Options

Before exporting a document to PDF, you can specify PDF-specific options in the Export Options panel.

EUD_HTML5DV_PdfExportOptions

General Options

Provides access to digital signatures. Select a signature to sign the document on export to PDF.

Convert Images to Jpeg

Specifies whether all bitmaps contained in the document should be converted to JPEG format during export to PDF.

Show Print Dialog on Open

Specifies whether the Print dialog should be displayed when the resulting PDF file is opened in an appropriate application.

Never Embedded Fonts

Specifies font names which should not be embedded into the resulting file. To separate fonts, use semicolons.

Export Editing Fields To AcroForms

Specifies whether to convert a report's editing fields to interactive forms.

Image Quality

Specifies the document's image quality level. The higher the quality, the bigger the file, and vice versa.

PDF A Compatibility

Specifies document compatibility with the PDF/A specification.

Specifies a range of pages which will be included in the resulting file. To separate page numbers, use commas. To set page ranges, use hyphens.

Rasterization Resolution

Specifies the image resolution for raster images.

Document Options

The Document Options complex property contains options which specify the Document Properties of the created PDF file. Click the complex property's header to access its nested options.

EUD_HTML5DV_PdfDocumentOptions

PDF Password Security Options

This complex property allows you to adjust the security options of the resulting PDF file.

EUD_HTML5DV_PdfSecurityOptions

Open Password

Specifies the password for opening the exported PDF document.

Encryption Level

Specifies the algorithm used to encrypt PDF content.

Permissions Password

Specifies the PDF permissions password for the document.

PDF Permissions Options

Provides access to the options which specify the permissions for printing, changing, copying, and accessing the exported document.

  • Improve this Doc

IMAGES

  1. Export to PDF

    export pdf devexpress

  2. Export to PDF

    export pdf devexpress

  3. Export to PDF

    export pdf devexpress

  4. Export to PDF

    export pdf devexpress

  5. How to: Export a Document to PDF Format

    export pdf devexpress

  6. How to: Export a Workbook to PDF

    export pdf devexpress

VIDEO

  1. DevExpress Ders 39 GridControl Verilerini Pdf'e Aktarma

  2. Export pdf

  3. DevExpress Ders 36 Export To Pdf ChartControl

  4. XtraReport in asp net c# video1 طريقة عمل التقرير

  5. DevExpress

  6. Auto PDF Export on Sales Voucher save

COMMENTS

  1. Export to PDF | .NET Reporting Tools | DevExpress Documentation

    Export in Code. Use the XtraReport.ExportToPdf or XtraReport.ExportToPdfAsync methods to export a report to PDF format. Specify the path/stream to which the report should be exported as the first argument in these methods. If you specify only the path/stream, the report is exported to PDF format with the default options.

  2. .NET PDF File API Library | C#, VB.NET | DevExpress

    sign PDF docs in deferred mode. The DevExpress PDF Document API allows you to attach files, add hyperlinks, create bookmarks and edit existing bookmarks within any PDF file. Create, remove, edit annotations, add comments and replies (including nested responses) to your PDF documents. Our PDF Document API supports the following text annotations ...

  3. PDF Export Options | DevExpress End-User Documentation

    General Options. Provides access to digital signatures. Select a signature to sign the document on export to PDF. Specifies whether all bitmaps contained in the document should be converted to JPEG format during export to PDF. Specifies whether the Print dialog should be displayed when the resulting PDF file is opened in an appropriate application.

  4. How to export a report as binary and store as pdf ...

    Hi Marlon, You can easily export any given XtraReport instance to PDF using the corresponding method (I must state though that your code snippet confuses me, as it exports one report in the BeforePrint handler of another report). In any case, you can just call the ExportToPdf method and save your PDF file to a MemoryStream object (using the ...