Interface StreamPrinter

  • All Known Subinterfaces:
    JPSStreamPrinter

    public interface StreamPrinter
    A representation of a virtual printer, that writes the output to an OutputStream instead of a physical printer.

    StreamPrinter may be used to generate a print stream based on a collection of pages.

    The most common way to access a StreamPrinter instance is, by using the StreamPrinterFactory. The StreamPrinterFactory defines some static methods to create instances of commonly used StreamPrinter instances.

    Example

    
       Document sourceDocument = // ... initialized somewhere else
       OutputStream output = // ... the designated output
    
       StreamPrinter psPrinter = StreamPrinterFactory.createPostscriptStreamPrinter();
       final Lock lock = sourceDocument.getPages().getReadWriteLock().getReadLock();
       lock.lock();
       try {
        // add all pages of a given document to the StreamPrinter
        psPrinter.getSourcePages().addAll(sourceDocument.getPages());
       } finally {
         lock.unlock();
       }
    
       psPrinter.print(output);
       output.close();
    
     
    • Method Detail

      • isAvailable

        boolean isAvailable()
        Determines, whether the given StreamPrinter instance is available. In some cases and on some systems not every StreamPrinter is available due to numerous restrictions like different implementations of the JavaVM.
        Returns:
        true if the StreamPrinter instance is available and can be used.
      • getSourcePages

        org.jadice.util.glazedlists.EventList<Page> getSourcePages()
        A EventList with pages that shall be printed.

        The contents of this EventList are the source pages that will be printed.

        Returns:
        never null. A mutable EventList of pages