Class PageToImageWorker

    • Constructor Detail

      • PageToImageWorker

        public PageToImageWorker()
    • Method Detail

      • work

        protected void work​(Stream stream)
                     throws Throwable
        Converts the pages of a document into images in the target format.
        Specified by:
        work in class StreamWorker<PageToImageNode>
        Parameters:
        stream - the input stream.
        Throws:
        Throwable - if an uncaught exception occurs.
      • convertPageToBufferedImage

        protected static BufferedImage convertPageToBufferedImage​(com.levigo.jadice.document.Page page,
                                                                  Dimension maximumSize)
        Converts the document page to a buffered image.
        Parameters:
        page - the given document page.
        Returns:
        the corresponding buffered image.
      • convertPageToTargetFormat

        protected static void convertPageToTargetFormat​(com.levigo.jadice.document.Page page,
                                                        PageToImageNode.Format targetFormatName,
                                                        Dimension maximumSize,
                                                        int colorModel,
                                                        float compressionQuality,
                                                        OutputStream out)
                                                 throws IOException
        Converts the current page to an input stream of the target format.
        Parameters:
        page - the document's page.
        targetFormatName - the desired target format.
        maximumSize - the maximum bounds of the image result.
        colorModel - a specified color model.
        compressionQuality - the desired compression quality 1.0f (no compression) - 0.0 (full compression)
        out - the OutputStream to which the image is written.
        Throws:
        IOException - if an I/O error occurs.
      • calcPNGCompressionLevel

        protected static int calcPNGCompressionLevel​(float compressionQuality)
        This method calculates the appropriate compression level for a given compression quality.
        Parameters:
        compressionQuality - the desired compression quality.
        Returns:
        the calculated compression level.
      • readDocument

        protected static com.levigo.jadice.document.Document readDocument​(Stream stream)
                                                                   throws com.levigo.jadice.document.JadiceException,
                                                                          IOException
        Read the stream into the document data structure.
        Parameters:
        stream - the document's stream.
        Returns:
        the corresponding document.
        Throws:
        com.levigo.jadice.document.JadiceException - if the document couldn't be read.
        IOException - if an I/O error occurs.