Class ConvertPagesToHiResImages


  • public final class ConvertPagesToHiResImages
    extends Object

    Image Extraction from PDF files


    This class provides a simple Java API to convert pages in a PDF files into images and also a static convenience method if you just want to dump all the pages as images from a PDF file or directory containing PDF files

    See our Support Page for Examples on Convert PDF pages to Images
    There is a simpler example (org.jpedal.examples.images.ConvertPagesToImages) for producing images of pages if extra features not needed

    • Constructor Detail

      • ConvertPagesToHiResImages

        public ConvertPagesToHiResImages​(String fileName)
        Sets up an ConvertPagesToHiResImages instance to open a PDF File
        Parameters:
        fileName - full path to a single PDF file
      • ConvertPagesToHiResImages

        public ConvertPagesToHiResImages​(byte[] byteArray)
        Sets up an ConvertPagesToHiResImages instance to open a PDF file contained as a BLOB within a byte[] stream
        Parameters:
        byteArray -
    • Method Detail

      • main

        public static void main​(String[] args)
      • writeAllPagesAsHiResImagesToDir

        public static void writeAllPagesAsHiResImagesToDir​(String inputDir,
                                                           String outputDir,
                                                           String format)
                                                    throws PdfException
        static method to write out all pages in a PDF files or directory of PDF files as images Not for use with other image conversion methods in multi-threaded environments. This method utilises some variables that may impact image conversion taking place on other threads.
        Parameters:
        inputDir - directory of files to convert
        outputDir - directory of output
        format - format of images
        Throws:
        PdfException - PdfException
      • setPassword

        public void setPassword​(String password)
        sets the Owner or User Password to use when opening encrypted PDF file
        Parameters:
        password - the USER or OWNER password for the PDF file
      • getPageCount

        public int getPageCount()
        number of pages in PDF file (starting at 1)
        Returns:
        page count
      • openPDFFile

        public boolean openPDFFile()
                            throws PdfException
        routine to open the PDF File so we can access - needs to be checked as will be false if file cannot be opened for any reason
        Returns:
        true if successful
        Throws:
        PdfException - is problem opening file
      • closePDFfile

        public void closePDFfile()
        ensure PDF file is closed once no longer needed and all resources released