Class PageFormatUtils


  • public class PageFormatUtils
    extends Object
    Helper for handling the various page formats used by the PDF converter implementations.
    Since:
    8.4.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • toPdfBoxFormat

        public static org.apache.pdfbox.pdmodel.common.PDRectangle toPdfBoxFormat​(ETargetPageFormat pageFormat,
                                                                                  org.apache.pdfbox.pdmodel.common.PDRectangle dfltFormat)
        Returns a page format value in points usable by PDFBox based converters.
        Parameters:
        pageFormat - the page format value to be processed
        dfltFormat - a format value in points to be returned if the page format is ETargetPageFormat.AUTO or unhandled
        Returns:
        the appropriate format value or the provided default format
      • toSizeInPoints

        public static PageFormatUtils.IntSize toSizeInPoints​(ETargetPageFormat pageFormat,
                                                             PageFormatUtils.IntSize dfltFormat)
        Returns a page format value usable by converters based on DTP points.
        Parameters:
        pageFormat - the page format value to be processed
        dfltFormat - a format value to be returned if the page format is ETargetPageFormat.AUTO or unhandled
        Returns:
        the appropriate format value or the provided default format
      • applyPdfPageFormat

        public static void applyPdfPageFormat​(byte[] sourcePdfBytes,
                                              OutputStream os,
                                              PageFormatUtils.IntSize targetSize)
                                       throws Exception
        Checks each page of a PDF document (provided with the byte array argument) and applies the provided page format. Only pages whose format differs from the desired format will be scaled accordingly. The result will be written to the provided output stream.
        Parameters:
        sourcePdfBytes - the PDF document as a byte array
        os - the target output stream to write the resulting PDF to
        targetSize - target page width and height in DTP points
        Throws:
        Exception - if unexpected problems occur
      • applyPdfPageFormat

        public static void applyPdfPageFormat​(com.aspose.pdf.Document pdfDocument,
                                              PageFormatUtils.IntSize targetSize)
        Checks each page of the provided PDF document and applies the provided page format. Only pages whose format differs from the desired format will be scaled accordingly. Note: The provided document will not be closed by this method.
        Parameters:
        pdfDocument - the PDF document to process
        targetSize - target page width and height in DTP points