Portable Document Format (PDF), is a format recommended for printing and exports. You can use the PDFRenderingExtension to render your report in this format. With the PDF rendering extension, you can use features such as font linking, digital signatures and end-user defined characters (EUDC). These features are only available in the Professional Edition of ActiveReports.
In order to render your report in PDF, add reference to the following assemblies in the project:
The following steps provide an example of rendering a report in PDF format.
Visual Basic.NET code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
' Provide the page report you want to render. Dim report As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("C:\Sample_PageReport.rdlx")) Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report) ' Create a output directory Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyPDF") outputDirectory.Create() ' Provide settings for your rendering output. Dim pdfSetting As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings() Dim setting As GrapeCity.ActiveReports.Extensibility.Rendering.ISettings = pdfsetting ' Set the rendering extension and render the report. Dim pdfRenderingExtension As New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension() Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name)) reportDocument.Render(pdfRenderingExtension, outputProvider, pdfSetting) |
C# code. Paste INSIDE the Form Load event. |
Copy Code
|
---|---|
// Provide the page report you want to render. GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"C:\Sample_PageReport.rdlx")); GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.ActiveReports.Document.PageDocument(report); // Create a output directory System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF"); outputDirectory.Create(); // Provide settings for your rendering output. GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings(); GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting; //Set the rendering extension and render the report. GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension(); GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name)); reportDocument.Render(pdfRenderingExtension, outputProvider, pdfSetting); |
ActiveReports offers several options to control how reports render to PDF.
Property | Description |
---|---|
Application | Set the value that appears for application in the Document Properties dialog of the PDF viewer application. |
Author | Enter the name of the author to appear in the Document Properties dialog of the PDF viewer application. |
CenterWindow | Set to True to position the document's window in the center of the screen. |
Columns | Set the number of columns to use in the report. This value overrides the report's original settings. The default value of -1 uses the report's original settings. |
ColumnSpacing | Enter a value in inches to set the amount of space between columns. This value overrides the report's original settings. |
DisplayMode | Specifies how the document is displayed when opened. FullScreen mode displays the document with no menu bar, window controls, or any other window visible. |
DisplayTitle | Set to True to display text you enter in the Title property. When set to False it displays the name of the PDF file. |
DpiX | Set the horizontal resolution of the rendered PDF file. |
DpiY | Set the vertical resolution of the rendered PDF file. |
Encrypt | Determines whether the document is encrypted or not. Note: If Encrypt is set to False, permissions and passwords have no effect. |
EndPage | The last page of the report to render. The default value is the value for StartPage, that is, 0. |
FallbackFonts | Gets or sets a comma-delimited string of font families to locate missing glyphs from the original font. |
FitWindow | True to resize the document’s window to fit the size of the first displayed page. Default value: false. |
HideMenubar | True to hide the viewer application’s menu bar when the document is active. Default value: false. |
HideToolbar | True to hide the viewer application’s toolbars when the document is active. Default value: false. |
HideWindowUI | True to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed. Default value: false. |
ImageInterpolation | Interpolation value of images. Allows to enable/disable image interpolation, when exporting the file to PDF. |
Keywords | Keywords associated with the document. |
MarginBottom | The bottom margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings. |
MarginLeft | The left margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings. |
MarginRight | The right margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings. |
MarginTop | The top margin value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings. |
OwnerPassword | The owner password that can be entered in the reader that permits full access to the document regardless of the specified user permissions. |
PageHeight | The page height value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings. |
PageWidth | The page width value, in inches, to set for the report. You must include an integer or decimal value followed by "in" (for example, 1in). This value overrides the report's original settings. |
Permissions | Specifies the user permissions for the document. Permissions can be combined using a comma between values. In order to use AllowFillin, AllowAccessibleReaders, and AllowAssembly permissions, you must set the Use128Bit property to True. |
PrintLayoutMode | Specifies layout mode to be used for PDF document. |
SizeToFit | Determines whether PDF pages are fit to the selected paper size or not. |
StartPage | The first page of the report to render. A value of 0 indicates that all pages are rendered. |
Subject | The subject of the document. |
Title | The title of the document. |
Use128Bit | True to use 128 bit encryption with full permissions capability. False to use 40 bit encryption with limited permissions |
UserPassword | The user password that can be entered in the reader. If this value is left empty, the user will not be prompted for a password, however the user will be restricted by the specified permissions. |
WatermarkAngle | Specify the degree of angle for the watermark text on the PDF document. Valid values range from 0 to 359, where 0 is horizontal, left to right. |
WatermarkColor | Select a color for the watermark text on the PDF document. The default value for the watermark color is gray, but you can select any Web, System, or Custom color. |
WatermarkFont | Set the font to use for the watermark to any valid System.Drawing.Font. |
WatermarkTitle |
Enter text (i.e. CONFIDENTIAL) to use as the watermark on the PDF document. |
PDF is considered as the best format for printing and it also supports interactive features like Document Map, Bookmarks and Hyperlinks. However, in case you have any data hidden (like in a drill-down report) at the time of rendering, it does not show up in the output. Therefore, it is recommended to expand all toggle items prior to rendering.