SmartJReport - (JTextArea - Print, PDF, TIFF, PostScript, PNG, BMP, GIF, JPG, JPEG and more)
Visit our website and learn more about SmartJReport that supports all of your Java
report, print, PDF and conversion requirements.
JTextArea - The Demo
This demo sample shows how to Print, PDF or simply preview an existing JTextArea. You can
"silent print your JTextArea" using the
which you can learn looking the at the sample Java programs under
In the downloaded archive you will see some sample batch programs (e.g.
). For each batch file there is a corresponding Java sample program made
available as part of the downloaded archive. Run the
(Unix/Linux) for example to see the following window with a
JTextArea and few buttons to "Print", "PDF" and "Preview" the report pages from JTextArea.
The Demo JTextArea
You can either "Silent print your JTextArea" or provide UI controls such as menus and
buttons as demonstrated in this sample program and print, PDF, preview and more.
When printing or previewing optionally you can choose to show a print dialog or a page
dialog depending on the parameters values in the
method. In this sample we show a "print dialog" to let user select a printer, paper,
orientation, copies and others as seen in the print dialog next.
This is how typical print dialog look like with various printing parameters.
Here is how the print preview window looks like when previewed instead of printing it to a printer directly.
The report engine can let you convert the JTextArea report pages to a PDF document. You can
convert JTextArea to PDF completely silently by getting a
JTextArea to PDF
JavaDocumentPrinter.Pageable() and then passing the
ConversionFactory.saveAsPdf(Pageable) method. Following are some
PDFs created out of sample Swing JTextArea component.
Report lets you preview JTextArea report pages in a preview window before printing or conversion
to other data formats.
JavaDocumentPrinter class has few
methods to call for showing the preview window. This demo chooses to show a paper selection
dialog before showing the preview window. It is also important to remember that the preview
window has options for the end user to Print, PDF and conversion to images. Preview window
also lets you zoom in and out in order to control number of pages to output.
Select paper size and orientation from this "Paper Selection" window.
JTextArea to PNG, BMP, GIF and JPEG/JPG
Look at the resized image creation samples such as
and other conversion samples in the downloaded archive.
There are ways to convert JTextArea report pages to many different image formats such as PNG,
BMP, GIF and JPEG/JPG. If you want to convert JTextArea to images silently we suggest you
to get a
Pageable (each page of which is an
JavaDocumentPrinter class and then pass the
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 JTextArea report pages. From the preview window you
can convert one or more of the JTextArea report pages to images.
JTextArea to TIFF
This is similar to the above. Get the
Pageable (convert to AbstractPage array)
ConversionFactory.saveAsTIFF(AbstractPage) to produce the TIFF report.
Also look at
Report2ResizedTiffDemo.java demo sample in the downloaded archive.
JTextArea to Post Script
Pageable and create an array of
ConversionFactory.saveAsPostScript(AbstractPage) to produce the
Post Script output of your JTreeTable report.
Also look at
Report2PostScriptDemo.java demo sample in the downloaded archive.