Back to Devexpress

RichEditDocumentServer.ExportToPdf(String) Method

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-dot-exporttopdf-x28-system-dot-string-x29.md

latest5.1 KB
Original Source

RichEditDocumentServer.ExportToPdf(String) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Exports the document content to the specified file path in PDF format.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public virtual void ExportToPdf(
    string fileName
)
vb
Public Overridable Sub ExportToPdf(
    fileName As String
)

Parameters

NameTypeDescription
fileNameString

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

|

Remarks

PDF Export features and limitations are detailed in the following document: Export to PDF.

Use the PdfExportOptions class instance to specify export settings. Pass this object as the method parameter.

csharp
using (var wordProcessor = new RichEditDocumentServer()) {
  wordProcessor.LoadDocument("Documents//MovieRentals.docx", DocumentFormat.Docx);

  // Export the document to the file:
  wordProcessor.ExportToPdf("Document_PDF.pdf");
}

System.Diagnostics.Process.Start("Document_PDF.pdf");
vb
Using wordProcessor = New RichEditDocumentServer()
  wordProcessor.LoadDocument("Documents//MovieRentals.docx", DocumentFormat.Docx)

  ' Export the document to the file:
  wordProcessor.ExportToPdf("Document_PDF.pdf")
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the ExportToPdf(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-enable-automatic-hyphenation/CS/Program.cs#L39

csharp
//Export the result to the PDF format
wordProcessor.ExportToPdf("Result.pdf");

word-document-api-use-track-changes/CS/word-processing-document-api-track-changes/Program.cs#L51

csharp
documentProcessor.ExportToPdf("DocumentWithAppliedRevisions.pdf");
System.Diagnostics.Process.Start("DocumentWithAppliedRevisions.pdf");

word-document-api-examples/CS/CodeExamples/ExportActions.cs#L98

csharp
// Save the document as a PDF file.
wordProcessor.ExportToPdf("Document_PDF.pdf");

word-document-api-enable-automatic-hyphenation/VB/Program.vb#L35

vb
'Export the result to the PDF format
wordProcessor.ExportToPdf("Result.pdf")

word-document-api-use-track-changes/VB/word-processing-document-api-track-changes/Program.vb#L49

vb
documentProcessor.ExportToPdf("DocumentWithAppliedRevisions.pdf")
System.Diagnostics.Process.Start("DocumentWithAppliedRevisions.pdf")

word-document-api-examples/VB/CodeExamples/ExportActions.vb#L89

vb
' Save the document as a PDF file.
wordProcessor.ExportToPdf("Document_PDF.pdf")
' Show the resulting PDF file.

See Also

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace