All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.

Export to PDF

  • 2 minutes to read

The exportToPdf method exports the current document to the portable document format (PDF) and invokes the PdfExporting event for further processing on the client side. Use the base64, blob, or blobStream event parameter to access the processed PDF document. You can set the handled property to true to prevent further processing on the server.

@(Html.DevExpress().RichEdit("richEdit")
  .OnPdfExporting(
    @"function(s, e) {
    e.handled = true;
    console.log(e.base64);
    }")

If the handled property is set to false or undefined, specify the ExportUrl(String) property to process the document on the server.

@(Html.DevExpress().RichEdit("richEdit")
  .Pdf(p => {
      p.ExportUrl(Url.Action("Export"));
  })
  .Fonts(f =>
  //...
)
public IActionResult Export(string base64, string fileName) {
    byte[] fileContents = System.Convert.FromBase64String(base64);
    return Ok();
}
NOTE

If you apply the [ApiController] attribute to your controller, you should add the [FromForm] attribute to parameters in the Export action.

public IActionResult Export([FromForm]string base64, [FromForm]string fileName) {
  byte[] fileContents = System.Convert.FromBase64String(base64);
  return Ok();
}

If document processing is implemented on the server, you can write the PdfExported event handler to perform custom actions after a server sends a response to a request for document processing.

IMPORTANT

When you export to PDF, you should upload a list of available fonts and their sources to the client and register the pdfkit library on your page.

Learn how to use the ExportUrl method in a Razor Pages web app.