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;
You can add custom fonts to the PDF exported document by adding the font streams to Fonts
collection in PDFOptions
instance.
To add custom fonts to the PDF exported document, follow these steps:
Add the font .ttf
files to your application App_Data/Resources
folder.
In the Solution Explorer, open the properties of the font file and set the Copy
property to Output Directory as Copy always.
Initialize the Font
collection and add the font stream to it.
The key value provided in the font collection should be same as in the report item font property.
//Load Missing font stream to the pdf document
writer.PDFOptions.Fonts = new Dictionary<string, System.IO.Stream>
{
{ "Segoe UI", new FileStream(System.Web.Hosting.HostingEnvironment.MapPath(@"\App_Data\Resources\Font_file_name.ttf"), FileMode.Open, FileAccess.Read) }
};
If any fonts used in the report definition is not installed or available in the local system, then you should load the font stream like above code snippet.
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"
};