Output as PDF (C#)
Set up and configure output to PDF from your reporting application. This option is useful if you want to archive or mail a document.
Example
This code snippet uses the
PDFRenderer
class:// code snippet starts
String designFile = "OrderReport.4rp";
String outputFilename = "SalesList.pdf";
FormatHandler handler = new FormatWriter(outputFilename);
PDFRenderer renderer = new PDFRenderer(handler);
renderer.JPEGquality = 0.5;
FourRpLayouter report = new FourRpLayouter(designFile, renderer);
//Run the report
report.debugLevel = 9;
// some code omitted - view full source in demo
report.runFromSerializable(data);
// open the file
System.Diagnostics.Process.Start(outputFilename);
// code snippet endsIn this example:
- A
FormatHandlerobject named handler is defined using theFormatWriterclass, taking the name of the output file as its input. - An object named
rendereris defined using thePDFRendererclass, takinghandleras input. - The
JPEGqualityproperty sets the compression quality of any included JPEG image to 0.5. A compression quality setting of 0.0 is interpreted as "high compression is important," while a setting of 1.0 is interpreted as "high image quality is important." FourRpLayouter report = new FourRpLayouter(designFile, renderer)creates the FourRpLayouter object for the specified report file that outputs a PDF file with the provided name.
For the full list of properties and methods for this renderer class, refer to the Genero Report Writer .NET API documentation.