Search results
Suggest a FeaturePDF

PDF Settings

The PDF export options provides properties to manage PDF export behaviors. You can set the customization properties in the PDFOptions. Refer to the following code snippet to initialize the PDFOptions property.

writer.PDFOptions = new PDFOptions();

Export with complex scripts

To export reports with the complex script language texts, set the ComplexScript property of PDFOptions instance to true.

writer.PDFOptions.EnableComplexScript = true;

PDF conformance

You can export the report as a PDF/A-1b document by specifying the PdfConformanceLevel.Pdf_A1B conformance level in the PdfConformanceLevel property.

writer.PDFOptions.PdfConformanceLevel = Syncfusion.Pdf.PdfConformanceLevel.Pdf_A1B;

Add custom fonts to PDF document

This section explains the steps to add custom fonts to the PDF exported document. The Report Writer provides Fonts property in PDFOptions to add the new fonts.

Any fonts used in the report that is not installed or not available in the local system, then you must add the font stream to Fonts property.

The following points should be followed while adding new fonts:

  1. Key should be same as in FontFamily element of the report item.
  2. Key is case sensitive, so casing is must match with FontFamily.
  3. To add streams for different font style, weight, styles consider the below,
    • Key should be in the format of {fontname} {weight} {style}. For example Roboto Light Italic.
    • Use only single white space between font name, weight, and style.
    • When FontStyle is set to Normal then use style as Regular. For example Roboto Light Regular.
    //Load missing font stream
    writer.PDFOptions.Fonts = new Dictionary<string, System.IO.Stream>
    {
        { "Roboto", new FileStream(basePath + @"\fonts\roboto\Roboto.ttf", FileMode.Open, FileAccess.Read) },
        { "Roboto Bold", new FileStream(basePath + @"\fonts\roboto\Roboto-Bold.ttf", FileMode.Open, FileAccess.Read) },
        { "Roboto Bold Regular", new FileStream(basePath + @"\fonts\roboto\Roboto-Bold.ttf", FileMode.Open, FileAccess.Read) },
        { "Roboto Light Italic", new FileStream(basePath + @"\fonts\roboto\Roboto-Light-Italic.ttf", FileMode.Open, FileAccess.Read) },
        { "Roboto Thin", new FileStream(basePath + @"\fonts\roboto\Roboto-Thin.ttf", FileMode.Open, FileAccess.Read) }
    };

In the above code, loaded the ttf streams for Roboto font with different style and weight combinations.

Password Protected PDF document

Allows you to protect the exported PDF document from unauthorized users by encrypting the document using encryption password. The following code snippet explains how to encrypt the exported document with user-defined password.

writer.PDFOptions.Security = new Syncfusion.Pdf.Security.PdfSecurity
{
    UserPassword = "Password"
};