The PDFPrinter is the basic implementation for generating PDF files. It only supports the base-14 fonts defined by the PDF standard. Because the base-14 fonts are guaranteed to exist in all PDF viewers, the generated files are very portable and compact. However, there are situations where other fonts need to be used in the PDF file in order to meet the formatting requirements.
For example, if the PDF document is generated using Unicode characters greater than 256, then it is a good idea to embed the fonts.
An enhanced PDF generation class, inetsoft.report.pdf.PDF3Printer, supports embedded fonts in the PDF file. Since the resulting PDF files use the same fonts as the reports, they more accurately reflect the report presentation. To support font embedding, the PDF generator needs to access the TrueType font files on the local file system. It parses the font file for font information otherwise not available from the Java API and loads the font data to embed into the PDF file.
The TrueType font directories need to be specified in the 'font.truetype.path' property. The property is a directory path and can contain multiple directories separated by a path separator (semicolon on Windows and colon on Unix). Only TrueType fonts on this path are used in PDF generation. On Windows NT, TrueType fonts are stored in the c:\winnt\fonts directory.
ReportEnv.setProperty("font.truetype.path", "c:/winnt/fonts;c:/otherfonts");
Type 1 font information is retrieved from AFM files. AFM is the standard font format used by Adobe to store font data. AFM Files can be downloaded from the Adobe Web site. The PDF generator uses font.afm.path to search AFM files for a Type 1 font. Applications using Type 1 fonts need to package the AFM files with the application and set the font.afm.path to point to the AFM directory.
![]() |
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software. |
Listing 2. PDF Generation with Embedded Fonts
import inetsoft.report.pdf.*; … FileOutputStream pdffile = …; ReportEnv.setProperty("font.truetype.path", "c:/winnt/fonts"); PDF3Printer pdf = new PDF3Printer(pdffile); report.print(pdf.getPrintJob()); pdf.close();
The PDF3Printer class is derived from the PDFPrinter class and shares the same methods for controlling PDF generation, such as image and text compression. It has additional methods for controlling the font embedding. By default, only font meta-data is embedded in the PDF files. For TrueType fonts, the entire font file can be embedded in the PDF file. This provides maximum portability at the price of larger file size.
pdf.setEmbedFont(true); // embed font file
If a font's file is not found on the specified font path, it is mapped to a base-14 Font in the same way as PDFPrinter.
Collection of Business Dashboard Examples - Below are examples of dashboards built with InetSoft's cloud-based dashboard software, some of which you can try out from our interactive gallery, plus several nice samples from competitors. This interactive census dashboard example of US census data uses multidimensional charting to display population, income, region, and property value, all in a single chart. Various filter elements enable possible patterns in the data to be discovered and explored...
Deviation Management Dashboard - The dashboard for Deviation Management Software serves as a central hub for users to monitor, analyze, and manage deviations from established processes, standards, or requirements within an organization. It provides real-time visibility into deviations, their status, impact, and resolution progress. Here are several key components and metrics that the developer might include on the dashboard...
Forex Trader Dashboards - A Forex trader's dashboard typically incorporates key performance indicators (KPIs) and analytics to provide a comprehensive view of market conditions, trading performance, and risk management. Here are some common KPIs and analytics used on a Forex trader's dashboard: Account Balance and Equity: Current Balance: The total amount of funds in the trading account. Equity: The account balance plus or minus any floating profits or losses. Profit and Loss (P&L) Metrics: Net Profit/Loss: The total profit or loss from all closed trades. Daily/Weekly/Monthly P&L: Breakdown of profits or losses over specific timeframes...
Time-Series Information Data Type - Data that is gathered over time is referred to as time-series data. It may consist of measurements of a single variable taken at several times or of many variables that vary over time. Stock prices, weather information, and sensor readings are a few examples of time-series data. In disciplines including engineering, economics, and finance, time-series data is often employed. Economists, for instance, examine historical patterns in inflation or unemployment rates using time-series data. Engineers utilize time-series data to track the functioning of equipment and forecast when maintenance or repairs will be required...
When Is Database Connection Pooling Used? - Connection pooling is especially beneficial for: Web applications: Handling multiple concurrent users where each user's request might involve database interactions. Enterprise applications: That need to serve many internal users simultaneously. Microservices: That communicate with a shared database and make frequent database calls. API-driven architectures: Where database operations occur frequently as part of backend logic for external requests...
Previous: PDF Printer |
Next: PDF Report Generation
|