Class PageFormatUtils
java.lang.Object
de.xima.fc.transform.pdf.convert.PageFormatUtils
Helper for handling the various page formats used by the PDF converter implementations.
- Since:
- 8.4.0
- Author:
- XIMA MEDIA GmbH
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classWraps 'Apache POI' (or to be more precise 'open xml word processing') page format settings.static final classWraps numeric page format constants used by Aspose, see e.g.static final classA 'record' that wraps width and height of a rectangle as integer values. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyPdfPageFormat(byte[] sourcePdfBytes, OutputStream os, PageFormatUtils.IntSize targetSize) Checks each page of a PDF document (provided with the byte array argument) and applies the provided page format.static voidapplyPdfPageFormat(com.aspose.pdf.Document pdfDocument, PageFormatUtils.IntSize targetSize) Checks each page of the provided PDF document and applies the provided page format.static ETargetPageFormatpageFormatFrom(PdfConversionParams params, ETargetPageFormat autoOverride) Reads the value of thePdfConversionParams.ParamNames.TARGET_PAGE_FORMATconversion parameter.toApachePoiFormat(ETargetPageFormat pageFormat, PageFormatUtils.ApachePoiPageFormat dfltFormat) Returns a page format value usable by Apache POI based converters.toAsposeCellsFormat(ETargetPageFormat pageFormat, PageFormatUtils.AsposePageFormat dfltFormat) Returns a page format value usable by Aspose.Cells based converters.toAsposeWordsFormat(ETargetPageFormat pageFormat, PageFormatUtils.AsposePageFormat dfltFormat) Returns a page format value usable by Aspose.Words based converters.static org.apache.pdfbox.pdmodel.common.PDRectangletoPdfBoxFormat(ETargetPageFormat pageFormat, org.apache.pdfbox.pdmodel.common.PDRectangle dfltFormat) Returns a page format value in points usable by PDFBox based converters.static PageFormatUtils.IntSizetoSizeInPoints(ETargetPageFormat pageFormat, PageFormatUtils.IntSize dfltFormat) Returns a page format value usable by converters based on DTP points.
-
Method Details
-
pageFormatFrom
public static ETargetPageFormat pageFormatFrom(PdfConversionParams params, ETargetPageFormat autoOverride) Reads the value of thePdfConversionParams.ParamNames.TARGET_PAGE_FORMATconversion parameter.- Parameters:
params- the PDF conversion parameters to processautoOverride- value to be returned if the parameter value isETargetPageFormat.AUTO(depending on the converter implementation this may also beETargetPageFormat.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 processeddfltFormat- a format value in points to be returned if the page format isETargetPageFormat.AUTOor 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 processeddfltFormat- a format value to be returned if the page format isETargetPageFormat.AUTOor 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 processeddfltFormat- a format value to be returned if the page format isETargetPageFormat.AUTOor 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 processeddfltFormat- a format value to be returned if the page format isETargetPageFormat.AUTOor 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 processeddfltFormat- a format value to be returned if the page format isETargetPageFormat.AUTOor 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 arrayos- the target output stream to write the resulting PDF totargetSize- 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 processtargetSize- target page width and height in DTP points
-