The requested page is not available for the requested platform. You are viewing the content for Default platform.

XtraReport.ExportToPdf(String) Method

Exports a report to the specified file path in PDF.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public void ExportToPdf(
    string path
)
Public Sub ExportToPdf(
    path As String
)

Parameters

Name Type Description
path String

A String which specifies the file name (including the full path) for the created PDF file.

Remarks

Once the document export has started, it will run until the resulting document is complete and cannot be interrupted or canceled in the process.

Use this method to export a report to a PDF file using its current PDF-specific export options. These options are represented by the PdfExportOptions object returned by the ExportOptions.Pdf property of a report's XtraReport.ExportOptions. This object provides the PdfExportOptions.ImageQuality, PdfExportOptions.NeverEmbeddedFonts and other properties which are intended to specify parameters of the resulting PDF file.

If you want to ignore current export options of a report, and use your specific settings when a report is exported to PDF, you should use the overloaded XtraReport.ExportToPdf method with the options parameter.

Note

This method overwrites any files present at the specified path that have the same file name without any warnings.

Note

For more information on using the ExportToPdf method, and limitations on export to PDF, please refer to the Export to PDF document.

Examples

This example illustrates how to export a report to PDF using the XtraReport.ExportToPdf method with specific PdfExportOptions applied.

Imports DevExpress.XtraPrinting
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
' ...

Namespace WindowsFormsApplication1
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
            ' A path to export a report.
            Dim reportPath As String = "c:\\Temp\Test.pdf"

            Using report As New XtraReport1()
                ' Specify PDF-specific export options.
                Dim pdfOptions As PdfExportOptions = report.ExportOptions.Pdf

                ' Specify the pages to be exported.
                pdfOptions.PageRange = "1, 3-5"

                ' Specify the quality of exported images.
                pdfOptions.ConvertImagesToJpeg = False
                pdfOptions.ImageQuality = PdfJpegImageQuality.Medium

                ' Specify the PDF/A-compatibility.
                pdfOptions.PdfACompatibility = PdfACompatibility.PdfA3b

                ' The following options are not compatible with PDF/A.
                ' The use of these options will result in errors on PDF validation.
                'pdfOptions.NeverEmbeddedFonts = "Tahoma;Courier New";
                'pdfOptions.ShowPrintDialogOnOpen = true;

                ' If required, you can specify the security and signature options. 
                'pdfOptions.PasswordSecurityOptions
                'pdfOptions.SignatureOptions

                ' If required, specify necessary metadata and attachments
                ' (e.g., to produce a ZUGFeRD-compatible PDF).
                'pdfOptions.AdditionalMetadata
                'pdfOptions.Attachments

                ' Specify the document options.
                pdfOptions.DocumentOptions.Application = "Test Application"
                pdfOptions.DocumentOptions.Author = "DX Documentation Team"
                pdfOptions.DocumentOptions.Keywords = "DevExpress, Reporting, PDF"
                pdfOptions.DocumentOptions.Producer = Environment.UserName.ToString()
                pdfOptions.DocumentOptions.Subject = "Document Subject"
                pdfOptions.DocumentOptions.Title = "Document Title"

                ' Checks the validity of PDF export options 
                ' and return a list of any detected inconsistencies.
                Dim result As IList(Of String) = pdfOptions.Validate()
                If result.Count > 0 Then
                    Console.WriteLine(String.Join(Environment.NewLine, result))
                Else
                    report.ExportToPdf(reportPath, pdfOptions)
                End If
            End Using

        End Sub

    End Class
End Namespace
See Also