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();
To export reports with the complex script language texts, set the ComplexScript
property of PDFOptions
instance to true
.
writer.PDFOptions.EnableComplexScript = true;
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;
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:
FontFamily
element of the report item.FontFamily
.{fontname} {weight} {style}
. For example Roboto Light Italic
.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 forRoboto
font with different style and weight combinations.
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"
};