Class PageFormatUtils

java.lang.Object
de.xima.fc.transform.pdf.convert.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 Details

    • pageFormatFrom

      public static ETargetPageFormat pageFormatFrom(PdfConversionParams params, ETargetPageFormat autoOverride)
      Reads the value of the PdfConversionParams.ParamNames.TARGET_PAGE_FORMAT conversion parameter.
      Parameters:
      params - the PDF conversion parameters to process
      autoOverride - value to be returned if the parameter value is ETargetPageFormat.AUTO (depending on the converter implementation this may also be ETargetPageFormat.AUTO)
      Returns:
      the parameter value or the provided override
    • 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
    • toAsposeCellsFormat

      public static PageFormatUtils.AsposePageFormat toAsposeCellsFormat(ETargetPageFormat pageFormat, PageFormatUtils.AsposePageFormat dfltFormat)
      Returns a page format value usable by Aspose.Cells based converters.
      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
    • toAsposeWordsFormat

      public static PageFormatUtils.AsposePageFormat toAsposeWordsFormat(ETargetPageFormat pageFormat, PageFormatUtils.AsposePageFormat dfltFormat)
      Returns a page format value usable by Aspose.Words based converters.
      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
    • 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
    • toApachePoiFormat

      public static PageFormatUtils.ApachePoiPageFormat toApachePoiFormat(ETargetPageFormat pageFormat, PageFormatUtils.ApachePoiPageFormat dfltFormat)
      Returns a page format value usable by Apache POI based converters.
      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