Huge Collections of Software Manuals and Knowledgebase

GreatManuals.com
Huge Collections of Software Manuals and Knowledgebase

 
Home Contact us Request to publish your help manuals Request to remove your help manuals Buy Now
Introduction
» J2PrinterWorks
» Print Samples and Screen Shots
» Sample Programs and Sample Code
» Installing and Uninstalling
» Pageable and Flowable
Using J2PrinterWorks
» J2Printer
» J2Printer14
» J2PrinterWebStart
» J2TextPrinter
» J2TablePrinter
» J2TreePrinter
» J2ListPrinter
» J2PanelPrinter
» J2ComponentPrinter
» J2FlowPrinter
» Working with HTML
» Utility Classes
» Converting from 1.x
» Class Diagram
» Removed Methods
Support Details
» Known Problems and Bug Reporting
» Frequently Asked Questions
» Technical Support
 
Buy J2PrinterWorks Online! Buy J2PrinterWorks Online!

Pageable & Flowable

Q1: What is a Pageable?
A: Pageable is a Java 2 interface that is part of the Java JDK as defined by Sun and which appears in the package java.awt.print . Pageable defines a set of paginated pages, i.e., a indexed sequence of printable pages. Pageable requires 3 implemented methods: getNumberOfPages() specifying the number of pages in the Pageable, getPrintable(int n) specifying the Printable (a Java 2 class that prints a single page) for the nth page, and getPageFormat(int n) specifying the PageFormat (another Java 2 class that describes the paper characteristics, i.e., orientation, size, margins) on which the nth page is to be printed. Printing a multi-page document in Java requires implementing a Pageable for your document content. This requires that you calculate in advance all the page breaks for your document content (not an easy task). J2PrinterWorks contains a number of components such as J2TextPrinter, J2TablePrinter, J2TreePrinter, J2ListPrinter, J2ComponentPrinter, and J2PanelPrinter that will take any JTextPane, JTable, JTree, JList, Component, or JPanel, respectively, and implement a corresponding Pageable.

Q2: What is a Flowable?
A: Flowable is an interface defined by Wildcrest Associates that appears in the package com.wildcrest.j2printerworks. Flowable defines a print operation that can be advanced by specified rectangular amounts through a given piece of content such as a JTextPane or a JTable, starting at the beginning and continuing in print order to the end. Flowable can be used to paginate a given piece of content starting and ending in the middle of any page, and a sequence of Flowables can be printed back-to-back over a series of pages. The J2PrinterWorks abstract class J2Pageable can take any individual Flowable and create a Pageable from it. For example, J2TextPrinter subclasses J2Pageable and implements the Flowable methods for any JTextPane and, as a result, J2Pageable implements the corresponding Pageable methods using these Flowable methods. In addition, the container class J2FlowPrinter can take any sequence of Flowables and create an overall Pageable as well as single Flowable from them.

Q3: Can I make my own Flowables?
A: Yes. By implementing the Flowable interface, you can create a printable component that can paginate and be intermixed back-to-back with other Flowable instances. Moreover, if you extend the abstract base class J2Pageable and implement its Flowable interface, you will also have a full J2PrinterWorks Pageable with support for headers, footers, margins, orientation, scale, etc.

data recovery utility downloads best data recovery software send group sms
photos recovery repair digital camera undelete usb files
recover usb drive data flash drive restore restore usb drive files

J2Printer, J2Printer14, and J2PrinterWebStart

Q1: What are the differences between J2Printer and J2Printer14?
A: J2Printer14 is a subclass of J2Printer. J2Printer14 inherits all the methods of J2Printer and adds several more methods that let you use the new Java printing features of JDK 1.4 including printer discovery, programmatic printer selection, printer attributes, and cross-platform print dialogs. J2Printer works under JDK 1.2.x, 1.3.x, 1.4.x, 1.5.x, or 1.6.x. J2Printer14 only works under JDK 1.4.x, 1.5.x, or 1.6.x.

Q2: What are the differences between J2Printer and J2PrinterWebStart?
A: J2PrinterWebStart is a subclass of J2Printer. J2PrinterWebStart inherits all the methods of J2Printer but implements them so they can run under the Java Web Start JNLP APIs. Since the Java Web Start JNLP APIs don't quite support all the printing capabilities of the full Java PrinterJob printing model, a few method that J2PrinterWebStart inherits from J2Printer have no effect under Java Web Start (see "J2Printer" section of this documentation).

Q3: Should I use the PrintRequestAttributeSet API or the J2Printer methods like setPaperSize to set my printing settings?
A: Either or both. You can set the values of the number of copies, print job name, paper size, orientation, and margins (printable area) using either API and even intermix calls from the two APIs under JDK 1.4.x or later. J2Printer14 will keep all the values in synch between the two systems, ensuring that setting values under either API will update the values under the other. However, it is probably a less confusing coding style to stay within one system or the other. Also, if you are using JDK 1.4.x or later, you are much better off using the PrintRequestAttributeSet style since it allows you to do many more things.

Q4: The cross-platform print dialog comes up saying Pages 1 to 1. Can this be fixed?
A: This is a bug in Java (see "Known Problems"). Java does show your number of pages correctly as the upper bound in the native print dialog. For the cross-platform dialog, you can fix this in your code by setting the PageRanges attribute:

PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new PageRanges(1,j2printer14.getPageable().getNumberOfPages()));
j2printer14.setPrintRequestAttributeSet(aset);

Q5: How can I "print to file"?
A: The user can always select the "print to file" option in the standard print dialog to save their printing output to a file instead of to an actual printer. If you wish to accomplish the same thing programatically, under JDK 1.4 or later, you can use the J2Printer14 class to specify the printer attribute javax.print.attribute.standard.Destination, which implements both the PrintJobAttribute and PrintRequestAttribute interfaces, in order to redirect your printing output to a local disk file, e.g., file:out.prn.

In addition, the J2Printer14 method printToPS can be used to send your printing output to a Postscript file.The J2Printer method printToHTML can be used to send your printing output to a series of HTML pages, including .jpg files for each of the individual page images. In addition, the J2Printer method getPageImage can be used to get an Image for any individual page and the method saveImageToFile can save such any Image to a file.

A printToPDF method has been added beginning with J2PrinterWorks 4.0 which can be used to send your printing output to a PDF file. This method requires the use of the free, open source component iText.jar available from http://www.lowagie.com/iText. In addition you can also use printToPS to create Postscript files and use 3rd party programs such as Adobe Acrobat Distliller or PS2PDF (part of Ghostscript) to convert these to PDF files. See the sample code provided in the J2Printer14 documentation under "Print to PDF".

Q6: The cross-platform print and page setup dialogs come up slow, what can be done about this?
A: Due to a bug in Java (Bug Parade 6233074), the cross-platform print and page setup dialogs on Windows can take as long as 10 seconds to come up the first time if your default printer is a network printer (the native dialogs are fast, the cross-platform dialogs after the first time are fast, having your default printer be a direct connect printer is fast). This bug has been reported to Sun. We have added a J2PrinterWorks feature to help mitigate this problem. When you call the J2Printer14 constructor, we start a separate low priority background thread which invisibly invokes the operations that are taking the 10 seconds. If the user invokes the print or page setup dialogs after these 10 seconds have passed, the dialogs will appear to them to come up right away. However, if the user invokes the print or page setup dialogs before the 10 seconds have passed, they will have to wait the remainder of the 10 seconds. Thus, if you are using cross-platform dialogs, be sure to instantiate J2Printer14 early in your application so as to get this 10 second start-up cost out of the way.

Q7: Hitting the "Print" button on the print preview dialog behaves differently than it used to, why?
A: Upon hitting the "Print" button on the print preview dialog, J2PrinterWorks used to always close the print preview dialog and bring up the print dialog (this is the same as applications such as Excel, Wordpad, and Photoshop). However, since the cross-platform print dialog can take a long time to come up (see Q6 above) this behavior makes it look like the application has died. In addition, if you hit "Cancel" on the print dialog, you really should go back to the print preview dialog. In the new design, by default when you hit the "Print" button, the print preview dialog stays up and displays a "busy" cursor. If the user hits "Cancel" on the print dialog, then the print preview dialog comes back to the front. If the user hits the "OK" (or "Print") button on the print dialog, then by default the print and print preview dialogs both go away and printing begins (this is the same as, for example, Internet Explorer). In addition, we have added a new J2Printer method setPrintPreviewCloseOnPrint(int) with arguments J2Printer.BEFORE, .WAIT, and .NEVER, where BEFORE means close the print preview before beginning the process of bringing up the print dialog (this is the former standard J2PrinterWorks behavior), WAIT (the new default behavior) means close the print preview dialog only after the user hits "OK" on the print dialog (this is the behavior of Internet Explorer), and NEVER means leave the print preview dialog up even after hitting "OK" (or "Print") on the print dialog (this is the same as Word, PowerPoint, Outlook, and Netscape).

« »

Buy J2PrinterWorks Online! Buy J2PrinterWorks Online!
Home | Contact Us | Request to publish your help manuals | Request to remove your help manuals