PdfSettingsBuilder.ExportUrl(String) Method

Specifies the path where the exported PDF document is sent for further processing.

Namespace: DevExpress.AspNetCore.RichEdit

Assembly: DevExpress.AspNetCore.RichEdit.v21.1.dll

Declaration

public PdfSettingsBuilder ExportUrl(
    string exportUrl
)

Parameters

Name Type Description
exportUrl String

The URL.

Returns

Type Description
PdfSettingsBuilder

An object that can be used to further configure PDF export settings.

Remarks

Set the ExportUrl property to process PDF document export on the server side.

NOTE

The ExportUrl property is not in effect if the PDF document export is implemented on the client side (the handled property is set to true).

@(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();
}

For Razor Pages web apps only

To use the ExportUrl method in a Razor Pages web app, it is necessary to add the following adjustments.

Disable the AntiForgeryToken option (enabled for Razor Pages web apps by default).

  • To disable the AntiForgeryToken for an application, add the following code to the ConfigureServices method in Startup.cs.

    services.AddMvc().AddRazorPagesOptions(o => {
        o.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
    });
    
  • To disable the AntiForgeryToken for a page, add the following code to a page model.

    [IgnoreAntiforgeryToken]
    public class IndexModel : PageModel {
        public void OnPost() {
        }
    }    
    

Declare a POST action handler to save a document.

 public void OnPostExport(string base64, string fileName) {
    byte[] fileContents = System.Convert.FromBase64String(base64);
 }

Use this handler in the ExportUrl method as follows.

    .ExportUrl("RichEditPage?handler=export") 

See also: .NET Core Application

See Also