PDF Report Generation:

PDF Bookmarks and Hyperlinks

PDF format supports bookmarks. Bookmarks are basically a hyperlink Table of Contents. The bookmarks can be displayed in a separate view than the document. Users can use the bookmark items to navigate in the document.

To produce PDF files with bookmarks, it is not adequate to just simulate a printer. A new class, PDF3Generator, is used to create PDF files from the report objects. The PDF3Generator uses a PDF3Printer for report data generation. It performs an extra pass at the beginning of the generation process to convert all report heading elements to PDF bookmarks.

Listing 3. PDF Generation with Table of Contents

import inetsoft.report.pdf.*;
…
FileOutputStream pdffile = …;
PDF3Generator pdf =
   PDF3Generator.getPDFGenerator(pdffile);
ReportSheet report = …;
pdf.generate(report);
// no close() necessary

If the report contains heading elements, they are converted to PDF bookmarks, including the heading elements in the subreports. The heading elements in the subreports can be ignored by setting the 'selectiveBookmarks' property to true. If you do not want to generate bookmarks for any of the heading elements in the report, use the PDF3Printer instead.

Listing 4. Using selectiveBookmarks setting

PDF3Generator.setSelectiveBookmarks(true);
boolean selective = PDF3Generator.isSelectiveBookmarks();
 
 

The bookmarks in the PDF file can be immediately opened when the PDF file is opened. This is achieved by setting the 'pdf.open.bookmark' property to true with the help of the 'setOpenBookmark()' method in PDFPrinter. In addition, if the bookmarks need not be opened immediately upon the opening of the file, then the property can be set to false. One can also check the current value of the pdf.open.bookmark property by using the 'isOpenBookmark()' method in the PDFPrinter.

Listing 5. Using openBookmark setting

 PDFPrinter.setOpenBookmark(true);
 boolean openBookmark = PDFPrinter.isOpenBookmark(); 

Similarly, the thumbnails included in the PDF file can also be opened immediately upon opening the PDF file. This setting is controlled by the 'pdf.open.thumbnail' property which can be set using the 'setOpenThumbnail()' method in PDFPrinter. The current value of this property can be checked using 'isOpenThumbnail()' method in PDFPrinter.

Listing 6. Using openThumbnail setting

 PDFPrinter.setOpenThumbnail(true);
 boolean openThumbnail = PDFPrinter.isOpenThumbnail(); 

Note that the properties pdf.open.bookmark and pdf.open.thumbnail are mutually exclusive properties. In the case where both are set to true, pdf.open.bookmark property will take priority. The PDF document may also contain hyperlinks inserted in the report. A report property, pdf.generate.links, controls whether the hyperlinks will be generated. This property is set to true by default. If set to false, the generation time of the file will be decreased.

More Articles About Reporting

Agricultural Enterprise Analytics - These analytics span across different domains and can include: Yield and Crop Analytics: Analysis of historical yield data to identify trends, patterns, and factors affecting crop productivity. Predictive analytics to forecast crop yields based on factors such as weather conditions, soil quality, and agricultural practices. Crop monitoring using satellite imagery, drones, and IoT sensors to track crop health, growth, and development in real-time. Optimization of planting strategies, irrigation schedules, fertilization practices, and pest management techniques to maximize yields while minimizing input costs and environmental impact. Supply Chain and Logistics Analytics: Optimization of supply chain networks to ensure efficient transportation, storage, and distribution of agricultural products. Analysis of demand patterns, market trends, and customer preferences to forecast demand and optimize inventory levels...

Definition of Data Friction - Any impediments or inefficiencies that prevent a company's data from flowing freely are referred to as data friction. Technical problems like mismatched systems, poor data quality, or ineffective data management techniques like manual data input, a lack of automation, or insufficient data storage and retrieval techniques are just a few examples of the many various ways that these barriers might appear...

Explaining Modern Analytics Ecosystems - For an organization to remain competitive, the capacity to make defensible judgments using this data is essential. This is where a contemporary analytics ecosystem is useful. A contemporary analytics ecosystem is a full-featured platform that allows businesses to gather, handle, analyze, and display data in order to derive insightful conclusions. The details of a contemporary analytics ecosystem are covered in this article...

User Defined Mashup with InetSoft - While OLAP cubes are a notable tool for data warehousing due to the preset definitions that aid in sorting and analyzing data, this feature inhibits the flexibility needed for data exploration and experimentation. Style Intelligence's robust data mashup engine can extract data from virtually any source, including OLAP cubes. Users can combine data with ease from even their own spreadsheets with data from disparate sources such as partner or vendor information...

Using In Memory Data Analytics Technology - The benefits of using in memory data analytics technology include: The ability to process large amounts of data without any lag time or delay. The ability to perform complex calculations and analysis with little or no wait time. The ability to work with live, real-time data and perform instant calculations, analysis, and predictions. The ability to combine different types of datasets into one unified system that can be queried simultaneously by multiple users...

Previous: Enhanced PDF Generation Class