Back to Devexpress

How to: Convert an HTML Document to PDF format

officefileapi-118947-word-processing-document-api-examples-document-conversion-how-to-convert-an-html-document-to-pdf-format.md

latest2.0 KB
Original Source

How to: Convert an HTML Document to PDF format

  • Sep 19, 2023

The following code sample shows how to export an HTML document to PDF format using the RichEditDocumentServer.ExportToPdf method.

View Example

csharp
server.LoadDocument("Documents\\TextWithImages.htm");
server.ExportToPdf("Document_PDF.pdf");
System.Diagnostics.Process.Start("Document_PDF.pdf");
vb
server.LoadDocument("Documents\TextWithImages.htm")
server.ExportToPdf("Document_PDF.pdf")
System.Diagnostics.Process.Start("Document_PDF.pdf")

Pass the PdfExportOptions instance to the RichEditDocumentServer.ExportToPdf method to specify the exporting options (image quality, additional metadata, etc.).

Note

Implement the IUriProvider descendant and override the IUriProvider.CreateCssUri or IUriProvider.CreateImageUri method to manage decoding external contents in an HTML file. It executes your method instead of the default one when the RichEditDocumentServer needs to load data from a specific URI. Refer to the How to: Retain the Image URI in HTML Document topic for details.

See Also

Use Word Processing Document API to Load HTML Files or Export Documents to HTML