Class PdfUtilities


  • public class PdfUtilities
    extends java.lang.Object
    PDF utilities based on Ghostscript or PDFBox with Ghostscript as default. If Ghostscript is not available on the system, then PDFBox is used. Call System.setProperty(PDF_LIBRARY, PDFBOX); to set PDFBox as default.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PDF_LIBRARY  
      static java.lang.String PDFBOX  
    • Constructor Summary

      Constructors 
      Constructor Description
      PdfUtilities()  
    • Method Summary

      Modifier and Type Method Description
      static java.io.File[] convertPdf2Png​(java.io.File inputPdfFile)
      Converts PDF to PNG format.
      static java.io.File convertPdf2Tiff​(java.io.File inputPdfFile)
      Converts PDF to TIFF format.
      static int getPdfPageCount​(java.io.File inputPdfFile)
      Gets PDF Page Count.
      static int getPdfPageCount​(java.lang.String inputPdfFile)
      Deprecated.
      As of Release 3.0.
      static void mergePdf​(java.io.File[] inputPdfFiles, java.io.File outputPdfFile)
      Merges PDF files.
      static void splitPdf​(java.io.File inputPdfFile, java.io.File outputPdfFile, int firstPage, int lastPage)
      Splits PDF.
      static void splitPdf​(java.lang.String inputPdfFile, java.lang.String outputPdfFile, java.lang.String firstPage, java.lang.String lastPage)
      Deprecated.
      As of Release 3.0.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PdfUtilities

        public PdfUtilities()
    • Method Detail

      • convertPdf2Tiff

        public static java.io.File convertPdf2Tiff​(java.io.File inputPdfFile)
                                            throws java.io.IOException
        Converts PDF to TIFF format.
        Parameters:
        inputPdfFile - input file
        Returns:
        a multi-page TIFF image
        Throws:
        java.io.IOException
      • convertPdf2Png

        public static java.io.File[] convertPdf2Png​(java.io.File inputPdfFile)
                                             throws java.io.IOException
        Converts PDF to PNG format.
        Parameters:
        inputPdfFile - input file
        Returns:
        an array of PNG images
        Throws:
        java.io.IOException
      • splitPdf

        public static void splitPdf​(java.lang.String inputPdfFile,
                                    java.lang.String outputPdfFile,
                                    java.lang.String firstPage,
                                    java.lang.String lastPage)
        Deprecated.
        As of Release 3.0.
        Splits PDF.
        Parameters:
        inputPdfFile - input file
        outputPdfFile - output file
        firstPage - begin page
        lastPage - end page
      • splitPdf

        public static void splitPdf​(java.io.File inputPdfFile,
                                    java.io.File outputPdfFile,
                                    int firstPage,
                                    int lastPage)
        Splits PDF.
        Parameters:
        inputPdfFile - input file
        outputPdfFile - output file
        firstPage - begin page
        lastPage - end page
      • getPdfPageCount

        public static int getPdfPageCount​(java.lang.String inputPdfFile)
        Deprecated.
        As of Release 3.0.
        Gets PDF Page Count.
        Parameters:
        inputPdfFile - input file
        Returns:
        number of pages
      • getPdfPageCount

        public static int getPdfPageCount​(java.io.File inputPdfFile)
        Gets PDF Page Count.
        Parameters:
        inputPdfFile - input file
        Returns:
        number of pages
      • mergePdf

        public static void mergePdf​(java.io.File[] inputPdfFiles,
                                    java.io.File outputPdfFile)
        Merges PDF files.
        Parameters:
        inputPdfFiles - array of input files
        outputPdfFile - output file