Class PrintUtil

java.lang.Object
de.tsl2.nano.util.PrintUtil

public class PrintUtil extends Object
provides generic print convenience methods for non-interactive prints.

NOTE-1: use 'PCL6 Driver for Universal Print' or 'PDFCreator' to test the printing.

NOTE-2: PCL-Problem: http://xmlgraphics.apache.org/fop/1.0/output.html:
If you run into the problem that the printed output is incomplete on Windows: this often happens to users printing to a PCL printer. There seems to be an incompatibility between Java and certain PCL printer drivers on Windows. Since most network-enabled laser printers support PostScript, try switching to the PostScript printer driver for that printer model.

Version:
$Revision$
Author:
Tom
  • Constructor Details

    • PrintUtil

      public PrintUtil()
  • Method Details

    • print

      public static DocPrintJob print(String fileName)
      delegates to #print(String, String, InputStream, PrintQuality, int, int[]...).
    • print

      public static DocPrintJob print(String printerName, String fileName)
      delegates to #print(String, String, InputStream, PrintQuality, int, int[]...).
    • print

      public static DocPrintJob print(String jobName, String printerName, InputStream stream, String mimeType, String username, MediaSizeName paperSize, PrintQuality quality, int priority, int[]... pageranges)
      prints through standard javax.print services
      Parameters:
      jobName - print job name
      printerName - to select a special available printer
      stream - stream to be sent to the printer
      mimeType - (optional) mime-type of stream content
      username - (optional) user-name to be used by the printer
      paperSize - (optional) something like MediaSizeName.ISO_A4.
      quality - (optional) quality one of enum PrintQuality
      priority - (optional) priority number between 1 and 100. if lower than 1, it will be ignored!
      pageranges - (optional) pageranges pages to be printed
      Returns:
      the started print job
    • print

      public static DocPrintJob print(String jobName, String printerName, InputStream stream, String mimeType, PrintRequestAttributeSet pras)
      prints through standard javax.print services
      Parameters:
      jobName - print job name
      printerName - to select a special available printer
      stream - stream to be sent to the printer. if null, a printer-info will be shown!
      mimeType - (optional) mime-type of stream content
      pras - additional print attributes
      Returns:
      the print job
    • getPrintService

      public static PrintService getPrintService(String printerName, String mimeType)
    • getPrintService

      public static PrintService getPrintService(String printerName, DocFlavor.INPUT_STREAM docFlavor, DocAttributeSet das)
    • printFOP

      public static void printFOP(File srcFile, String mimeType, File xsltFile, String printerName)
      convenience to send an apache-fop transformed file to the given printer. delegates to XmlGenUtil.fop(File, String, File) and print(String, String, InputStream).
    • main

      public static void main(String[] args)