PDF Settings
To control how the Bold Reports® ASP.NET Core Report Writer exports PDF documents, set the customization properties in the PDFOptions. Initialize the PDFOptions property with the following code snippet:
writer.PDFOptions = new PDFOptions();How do I export reports with complex script text?
To export reports with complex script language text to PDF in the Report Writer, set the ComplexScript property of the PDFOptions instance to true.
writer.PDFOptions.EnableComplexScript = true;How do I export a report as a PDF/A-1b document?
To export a report as a PDF/A-1b document with the Report Writer, set the PdfConformanceLevel property to the PdfConformanceLevel.Pdf_A1B conformance level.
writer.PDFOptions.PdfConformanceLevel = Syncfusion.Pdf.PdfConformanceLevel.Pdf_A1B;How do I add custom fonts to the PDF document?
To add custom fonts to a PDF document exported by the Report Writer, add the font streams to the Fonts property in PDFOptions.
If a font used in the report is not installed or not available in the local system, you must add the font stream to the
Fontsproperty.
Follow these rules when you add new fonts:
- Key should be same as in
FontFamilyelement of the report item. - Key is case sensitive, so the casing must match
FontFamily. - To add streams for different font styles and weights, follow these rules:
- Key should be in the format of
{fontname} {weight} {style}. For exampleRoboto Light Italic. - Use only single white space between font name, weight, and style.
- When
FontStyleis set toNormalthen use style asRegular. For exampleRoboto Light Regular.
- Key should be in the format of
//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) }
};The preceding code loads the
ttfstreams for theRobotofont with different style and weight combinations.
How do I password protect an exported PDF document?
To protect a PDF document exported by the Report Writer from unauthorized users, encrypt it with a password in the Security property of PDFOptions. The following code snippet encrypts the exported document with a user-defined password.
writer.PDFOptions.Security = new Syncfusion.Pdf.Security.PdfSecurity
{
UserPassword = "Password"
};