Class TextFilePrinterDriver

  • All Implemented Interfaces:
    PrinterDriver

    public class TextFilePrinterDriver
    extends Object
    implements PrinterDriver
    This printer driver will ignore all TextChunk encodings, as it makes no sense to have more than one encoding type in a plain text file.
    • Constructor Detail

      • TextFilePrinterDriver

        public TextFilePrinterDriver​(OutputStream out,
                                     float charsPerInch,
                                     float linesPerInch)
      • TextFilePrinterDriver

        public TextFilePrinterDriver​(OutputStream out,
                                     float charsPerInch,
                                     float linesPerInch,
                                     boolean unixEndOfLine)
    • Method Detail

      • endPage

        public void endPage​(boolean overflow)
                     throws IOException
        Ends the current page. Should print empty lines or an FORM_FEED command.
        Specified by:
        endPage in interface PrinterDriver
        Parameters:
        overflow -
        Throws:
        IOException - if there was an IOError while writing the command
      • getCharactersPerInch

        public float getCharactersPerInch()
        Gets the default character width in CPI.
        Specified by:
        getCharactersPerInch in interface PrinterDriver
        Returns:
        the default character width in CPI.
      • getLinesPerInch

        public float getLinesPerInch()
        Gets the default line height.
        Specified by:
        getLinesPerInch in interface PrinterDriver
        Returns:
        the default line height.
      • printChunk

        public void printChunk​(PlaintextDataChunk chunk)
                        throws IOException
        Prints a single text chunk at the given position on the current line. The chunk should not be printed, if an previous chunk overlays this chunk.
        Specified by:
        printChunk in interface PrinterDriver
        Parameters:
        chunk - the chunk that should be written
        Throws:
        IOException - if an IO error occured.
      • printEmptyChunk

        public void printEmptyChunk​(int count)
                             throws IOException
        Prints an empty chunk. This is called for all undefined chunk-cells.
        Specified by:
        printEmptyChunk in interface PrinterDriver
        Throws:
        IOException - if an IOError occured.
      • printRaw

        public void printRaw​(byte[] raw)
                      throws IOException
        Prints some raw content. This content is not processed in any way, so be very carefull.
        Specified by:
        printRaw in interface PrinterDriver
        Parameters:
        raw - the content that should be printed.
        Throws:
        IOException
      • startPage

        public void startPage​(Paper paper,
                              String encoding)
                       throws IOException
        Resets the printer and starts a new page. Prints the top border lines (if necessary).
        Specified by:
        startPage in interface PrinterDriver
        Throws:
        IOException - if there was an IOError while writing the command
      • getEndOfLine

        public char[] getEndOfLine()
      • setEndOfLine

        public void setEndOfLine​(char[] endOfLine)
      • getEndOfPage

        public char[] getEndOfPage()
      • setEndOfPage

        public void setEndOfPage​(char[] endOfPage)