PDF Printer

The PDF Printer is a simpler version of the PDF3Generator. The PDFPrinter lacks support for generating tables and TOC (Table of Contents). To create a PDFPrinter, pass a File object or a FileOutputStream to the constructor:

PDFPrinter pdf = new PDFPrinter(new File("report.pdf")); 

Once a PDFPrinter object is created, a PrintJob can be retrieved from it by calling getPrintJob():

report.print(pdf.getPrintJob()); 

After printing is done, we need to close the PDF stream:

pdf.close(); // or pdf.getPrintJob().end(); 

It is important to close the PDF stream after printing. Otherwise, the PDF file may not be complete. The PDF output can be closed by either calling the end() method on the PrintJob object returned by the PDFPrinter, or by calling the close() method on the PDFPrinter directly.

Compressed PDF

There are a few options that control how PDF files are generated. By default, text and images in a document are compressed. Since InetSoft products only support Zip compression, the generated document requires Acrobat Reader version 3.0 or later. If the PDF file needs to be compatible with earlier versions, the compression can be turned off manually:

 pdf.setCompressText(false);
 pdf.setCompressImage(false); 

Note: The compression needs to be turned off for CJK operating systems. Otherwise some of the binary data will be corrupted in the PDF file.If compression is turned off, you risk the possibility of a large PDF file. This is especially true if you use images or painters in a report.

Font Handling in PDF (Base-14 Fonts)

Another difference in printing a PDF file is the handling of fonts. In PDF, 14 fonts are guaranteed to exist in a viewer. They are called the base14 fonts. The base14 fonts are listed below:

  • courier
  • courier-bold
  • courier-boldoblique
  • courier-oblique
  • helvetica
  • helvetica-bold
  • helvetica-boldoblique
  • helvetica-oblique
  • symbol
  • times-bold
  • times-bolditalic
  • times-italic
  • times-roman
  • zapfdingbats

In order to ensure maximum portability, the Java font objects are mapped into the base14 fonts when generating PDF files.

Table 8. Default mapping between Java Fonts and Base-14 Fonts

Java Font Name

Base14 Font Name

Dialog

Helvetica

Dialoginput

Courier

Serif

Times

SansSerif

Helvetica

Monospaced

Courier

This mapping can be changed:

pdf.putFontName("dialog", "Times"); 

By default the PDFPrinter assumes the output page is letter size (8.5 x 11). To change this, set the page size property:

// switch width and height to print in landscape
pdf.setPageSize(11, 8.5);
// or print on A4 paper
pdf.setPageSize(StyleConstants.PAPER_A4); 

More Articles About Reporting

Create a Leads Summary Report - This document will explain how to create a Leads Summary Report using report creation software from InetSoft. A working version of this report can be found on the InetSoft Gallery. This report consists primarily of a single chart and a single crosstab, along with a variety of text. Below, we will examine how you can create these different components using the browser-based Ad Hoc Reporting feature...

Federated Ad Hoc Approach - The federated, ad hoc approach to data services and the Service-Oriented Architecture (SOA) approach represent two fundamentally different paradigms in how organizations structure, manage, and deliver data and services. Their differences reflect opposing philosophies in terms of control, design, governance, and flexibility. 1. Architectural Philosophy SOA Approach: Centralized and Structured: SOA is characterized by a centralized, structured approach to service design and deployment. It is built on the principle that services should be reusable, loosely coupled, and adhere to well-defined standards. SOA emphasizes the creation of a cohesive and integrated architecture where services are carefully designed and orchestrated to work together seamlessly across an organization...

Good Solution for Crystal Reports Conversion - Free Migration Assessment We have experience with many Crystal Reports migrations. We can assess your current reports and accelerate your conversions. Built-in, in-depth interactivity and customization allows business users to dynamically reshape pre-designed reports for changing business needs with zero training. Ad hoc reporting further empowers business users with direct access to underlying data assets in a governed and secure environment...

Medical Device Manufacturing Business Intelligence Tools - A medical device manufacturer faced multifaceted challenges, including suboptimal production planning, quality control issues, lack of supply chain visibility, and limited understanding of market trends. These challenges were impeding their ability to meet demand effectively and innovate in line with customer preferences. The medical device manufacturer, a prominent player in the medical device manufacturing sector, encountered a myriad of operational challenges that necessitated a strategic intervention. One significant hurdle revolved around the intricacies of production planning, where inaccurate demand forecasting hindered the company's ability to optimize production schedules and resulted in the accumulation of excess inventory. Additionally, maintaining consistent quality across the manufacturing process posed a formidable challenge, leading to occasional defects and recalls that impacted the company's reputation...

Pension Administration Dashboards - Pension administration involves managing complex processes, from enrolling new members to ensuring timely payments to retirees. As pension funds grow in size and complexity, administrators increasingly rely on dashboards to monitor and manage their operations. These dashboards track key performance indicators (KPIs) and metrics that provide insights into the health of the pension fund, the efficiency of administrative processes, and the satisfaction of members. In this analysis, we will explore various KPIs and metrics commonly tracked in pension administration dashboards, define these KPIs, and discuss their significance in performance management. 1. Member Enrollment and Demographics...

Why Use a Candlestick Chart? - There are several benefits to using Candlestick charts, besides the fact that they are a standard representational device for many financial applications. They are easy to read and interpret: Candlestick charts are visually appealing and provide a lot of information at a glance. They can highlight trend reversals: Candlestick patterns, such as the "hammer," "inverted hammer," "doji," "double-bottom," and "double-top" can signal that a trend may be reversing. They can show the sentiment of the market: A candlestick chart can help traders understand whether buyers or sellers are in control of the market at a given time...

Previous: Import and Export Report File Formats