Class PdfUtility


  • public class PdfUtility
    extends java.lang.Object
    A class containing some helper methods for PDFs.
    • Constructor Summary

      Constructors 
      Constructor Description
      PdfUtility()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void createWaterMarkedPdf​(java.io.File inputFile, java.io.File outputFile, java.lang.String phrase, int fontSize, float opacity, float rotation)
      Takes a given source PDF file, creates a copy output PDF file in which a watermark has been applied.
      static void createWaterMarkedPdf​(java.lang.String inputFile, java.lang.String outputFile, java.lang.String phrase, int fontSize, float opacity, float rotation)
      Takes a given source PDF file, creates a copy output PDF file in which a watermark has been applied.
      static void mergePdfFiles​(java.io.File outputFile, java.util.List<java.io.File> inputFiles, boolean createBookmarks, java.util.List<java.lang.String> bookmarkTitles)
      Merges multiple PDF files into a single PDF file.
      static void mergePdfFiles​(java.lang.String outputFile, java.util.List<java.lang.String> inputFiles, boolean createBookmarks, java.util.List<java.lang.String> bookmarkTitles)
      Merges multiple PDF files into a single PDF file.
      static void waterMarkPrintedImages​(java.io.File tempDirectory, java.util.Collection<nuix.Item> items, java.lang.String phrase, int fontSize, float opacity, float rotation, java.util.function.BiConsumer<java.lang.Integer,​java.lang.Integer> progressCallback)
      This method applies water marks to printed images of items.
      static void waterMarkPrintedImages​(java.lang.String tempDirectory, java.util.Collection<nuix.Item> items, java.lang.String phrase, int fontSize, float opacity, float rotation, java.util.function.BiConsumer<java.lang.Integer,​java.lang.Integer> progressCallback)
      This method applies water marks to printed images of items.
      • Methods inherited from class java.lang.Object

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

      • PdfUtility

        public PdfUtility()
    • Method Detail

      • mergePdfFiles

        public static void mergePdfFiles​(java.io.File outputFile,
                                         java.util.List<java.io.File> inputFiles,
                                         boolean createBookmarks,
                                         java.util.List<java.lang.String> bookmarkTitles)
                                  throws java.lang.Exception
        Merges multiple PDF files into a single PDF file. Optionally can create book marks corresponding to the beginning page of each constituent PDFs.
        Parameters:
        outputFile - File path for merged PDF which will be generated
        inputFiles - The input files to be merged
        createBookmarks - Whether to create book marks on each page which represent the first page of each input PDF
        bookmarkTitles - Optional list of book mark titles, if not provided sequential numbers will be used.
        Throws:
        java.lang.Exception - Thrown if an error occurs
      • mergePdfFiles

        public static void mergePdfFiles​(java.lang.String outputFile,
                                         java.util.List<java.lang.String> inputFiles,
                                         boolean createBookmarks,
                                         java.util.List<java.lang.String> bookmarkTitles)
                                  throws java.lang.Exception
        Merges multiple PDF files into a single PDF file. Optionally can create book marks corresponding to the beginning page of each constituent PDFs.
        Parameters:
        outputFile - File path for merged PDF which will be generated
        inputFiles - The input files to be merged
        createBookmarks - Whether to create book marks on each page which represent the first page of each input PDF
        bookmarkTitles - Optional list of book mark titles, if not provided sequential numbers will be used.
        Throws:
        java.lang.Exception - Thrown if an error occurs
      • createWaterMarkedPdf

        public static void createWaterMarkedPdf​(java.lang.String inputFile,
                                                java.lang.String outputFile,
                                                java.lang.String phrase,
                                                int fontSize,
                                                float opacity,
                                                float rotation)
                                         throws java.lang.Exception
        Takes a given source PDF file, creates a copy output PDF file in which a watermark has been applied.
        Parameters:
        inputFile - The source PDF file
        outputFile - The destination PDF file
        phrase - The water mark's phrase
        fontSize - The font size of the water mark
        opacity - How transparent the water mark is
        rotation - How rotated the water mark text should be
        Throws:
        java.lang.Exception - Thrown if: Input file does not exist, error creating stream to output file, error creating PDFReader or PDFStamper.
      • createWaterMarkedPdf

        public static void createWaterMarkedPdf​(java.io.File inputFile,
                                                java.io.File outputFile,
                                                java.lang.String phrase,
                                                int fontSize,
                                                float opacity,
                                                float rotation)
                                         throws java.lang.Exception
        Takes a given source PDF file, creates a copy output PDF file in which a watermark has been applied.
        Parameters:
        inputFile - The source PDF file
        outputFile - The destination PDF file
        phrase - The water mark's phrase
        fontSize - The font size of the water mark
        opacity - How transparent the water mark is
        rotation - How rotated the water mark text should be
        Throws:
        java.lang.Exception - Thrown if: Input file does not exist, error creating stream to output file, error creating PDFReader or PDFStamper.
      • waterMarkPrintedImages

        public static void waterMarkPrintedImages​(java.lang.String tempDirectory,
                                                  java.util.Collection<nuix.Item> items,
                                                  java.lang.String phrase,
                                                  int fontSize,
                                                  float opacity,
                                                  float rotation,
                                                  java.util.function.BiConsumer<java.lang.Integer,​java.lang.Integer> progressCallback)
                                           throws java.lang.Exception
        This method applies water marks to printed images of items. Each item has a PDF exported, from which a water marked copy is generated. The water marked copy is then imported back in to Nuix as the new printed image of the given item.
        Parameters:
        tempDirectory - Temp directory PDFs are exported to, generated in and imported from.
        items - The items which will be water marked.
        phrase - The water mark's phrase
        fontSize - The font size of the water mark
        opacity - How transparent the water mark is
        rotation - How rotated the water mark text should be
        progressCallback - A BiConsumer function which will be invoked as progress is made. Will be provided 2 integers, the first is the current progress value, the second the total progress.
        Throws:
        java.lang.Exception - Thrown if something goes wrong.
      • waterMarkPrintedImages

        public static void waterMarkPrintedImages​(java.io.File tempDirectory,
                                                  java.util.Collection<nuix.Item> items,
                                                  java.lang.String phrase,
                                                  int fontSize,
                                                  float opacity,
                                                  float rotation,
                                                  java.util.function.BiConsumer<java.lang.Integer,​java.lang.Integer> progressCallback)
                                           throws java.lang.Exception
        This method applies water marks to printed images of items. Each item has a PDF exported, from which a water marked copy is generated. The water marked copy is then imported back in to Nuix as the new printed image of the given item.
        Parameters:
        tempDirectory - Temp directory PDFs are exported to, generated in and imported from.
        items - The items which will be water marked.
        phrase - The water mark's phrase
        fontSize - The font size of the water mark
        opacity - How transparent the water mark is
        rotation - How rotated the water mark text should be
        progressCallback - A BiConsumer function which will be invoked as progress is made. Will be provided 2 integers, the first is the current progress value, the second the total progress.
        Throws:
        java.lang.Exception - Thrown if something goes wrong.