SmartJReport - preview images of the example JTables


PDF JTable

The report engine can let you convert the JTable report pages to a PDF document. You can convert JTable to PDF completely silently by getting a Pageable from calling JavaTablePrinter.Pageable() and then passing the Pageable to the ConversionFactory.saveAsPdf(Pageable) method. Following are some PDFs created out of sample Swing JTable component.

JTable to PDF (PDF simple JTable)

  • Fit to page width
  • No fit to page width
  • JTable to PDF (PDF Status Cell JTable)

  • Fit or without fit to page width
  • JTable to PDF (PDF custom string cell JTable)

  • Fit to page width
  • No fit to page width
  • JTable to PDF (PDF fruit cell JTable)

  • Fit to page width
  • No fit to page width
  • JTable to PDF (PDF JTextArea cell JTable)

  • Fit to page width
  • No fit to page width
  • Print and PDF Java JTable with colored cells as status

    Next is a complex JTable with cell values consists of strings and numbers, and are presented with a background color. The cells are presented with apporpirate colors to know the status of the remote object presented in a cell. The output is produced with absolute control over the content of each cell. It uses the Smart JReport power to produce this preview output next to it. See the online demo page for the PDF output for the same. In addittion to printing, using this Java report API you can produce PDF, TIFF, PostScript, PNG, GIF, BMP, JPEG/JPG and more.

    Status Renderer JTable

    Preview page 1

    Print and Generate PDF from complex JTable

    Next is a complex JTable with cell values consists of Strings and Icons in its rows as well as headers. The preview pages of the sample JTable is shown next to it.

    The complex JTable

    Preview page 1

    Print and PDF Java JTable with custom fonts

    This table consists of String and Date columns. The Date column is renderered with a custom renderer

    Status Renderer JTable

    Preview page 1

    Print and PDF JTable with JTextArea, JTextPane cells

    It lets you Print, PDF JTable output with swing text rendering component such as JTextArea and JTextPane so that the content can be easily presented as styled text in combination with icons etc. such kind of JTable cells can be easily printed and PDF generated. The example JTable shown next has a description column and is displayed using a JTextArea cell renderer. When printed, previewed and PDF generated, the output column width and height is controlled to wrap the text in a rectangular area as seen in the preview window shown next to it.

    The preview window shows how the JTable output look like after the table cells are rendered by the API. The text in the JTextArea cells under description column are renderered as wished.

    Print and Generate PDF from simple JTable

    Following is an image of a simple JTable consists of String cell values. Some cells has null value in it. Next to it is the preview pages created using API provided preview option (optionally you can show this window to the user for previewing all pages before printing and PDF generation of the pages).

    The simple JTable

    Preview page 1

    Print/Generate PDF from multiple JTable and mixed Swing components

    It is truly smart and allows you to print multiple swing components together. Run the online demo and look at the examples to know how to do that? You can add images, texts, JTables (or other swing components together). You can print the components, texts, icons together and generate a PDF document for viewing with Adobe Reader. Shown next is a JTextPane where JTables, images, and RTF texts added for printing all of them together.

    Preview pages of the above JTable

    JTable to PNG, BMP, GIF and JPEG/JPG

    Look at the resized image creation samples such as Report2ResizedPNG.java, Report2ResizedBMP.java, Report2ResizedGIF.java, Report2ResizedJPEG.java and other conversion samples in the downloaded archive.

    There are ways to convert JTable report pages to many different image formats such as PNG, BMP, GIF and JPEG/JPG. If you want to convert JTable to images silently we suggest you to get a Pageable (each page of which is an AbstractPage) form the JavaTablePrinter class and then pass the Pageable to the ConversionFactory.saveAsBMP(AbstractPage) (BMP), ConversionFactory.saveAsPNG(AbstractPage) (PNG), ConversionFactory.saveAsGIF(AbstractPage) (GIF), ConversionFactory.saveAsJPEG(AbstractPage) (JPEG), ConversionFactory.saveAsJPG(AbstractPage) (JPG) to convert to images. Conversion APIs provide the option to pass a resize factor so the output images size can be enlarged or shrinked.

    This demo sample lets you preview the JTable report pages. From the preview window you can convert one or more of the JTable report pages to images.

    JTable to TIFF

    This is similar to the above. Get the Pageable (convert to AbstractPage[] array) and call ConversionFactory.saveAsTIFF(AbstractPage[]) to produce the TIFF report.

    Also look at Report2ResizedTiffDemo.java demo sample in the downloaded archive.

    JTable to Post Script

    Get the Pageable and create an array of AbstractPage[] then call ConversionFactory.saveAsPostScript(AbstractPage[]) to produce the Post Script output of your JTable report.

    Also look at Report2PostScriptDemo.java demo sample in the downloaded archive.