cfpdf action="getinfo" does not return PageRotations or PageSizes properties

Description

There is an incompatibility between Lucee and Adobe ColdFusion with cfpdf(action="getInfo");

In ACF, the returned struct includes the following properties:

  • PageRotations - an array of rototion values of 0, 90, 180, 270 for each page in the PDF

  • PageSizes - an array of structs with width and height values for each page in the PDF (taken from TrimBox)

In Lucee, the PageRotations and PageSizes properties are not returned at all.

Activity

Pothys - MitrahSoft 28 August 2019 at 06:05

I've checked and added a features of Page Sizes and PageRotations for cfpdf if action="getinfo".

Pull Request: https://github.com/lucee/extension-pdf/pull/6/

Ben Reid 22 August 2019 at 06:20

For the benefit of others stumbling upon this issue I will provide the work-around code to leverage the PDFBox 2.0.16 library.

// VARIABLES TO HOLD THE RESULTS PageRotations = ArrayNew(1); PageSizes = ArrayNew(1); // OPEN THE PDF USING APACHE PDFBox LIBRARY objPDDocument = CreateObject("java", "org.apache.pdfbox.pdmodel.PDDocument").load(FileReadBinary(ARGUMENTS.Source)); // DETERMINE THE NUMBER OF PAGES NoOfPages = objPDDocument.getNumberOfPages(); // GET THE PAGES objPages = objPDDocument.getDocumentCatalog().getPages(); // GET PAGE ITERATOR objPageIterator = objPages.iterator(); // LOOP OVER THE PAGES ThisPageNo = 0; while (objPageIterator.hasNext()) { // GET THE NEXT PAGE objPage = objPageIterator.next(); // TRACK WHICH PAGE WE ARE PROCESSING ThisPageNo += 1; // DETERMINE THE PAGE ROTATION PageRotations[ThisPageNo] = objPage.getRotation(); // DETERMINE THE PAGE SIZE PageSizes[ThisPageNo] = { "width" = objPage.getTrimBox().getWidth(), "height" = objPage.getTrimBox().getHeight() }; } // ALWAYS CLOSE THE FILE objPDDocument.close();
Fixed

Details

Assignee

Reporter

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Priority

Created 22 August 2019 at 06:05
Updated 8 September 2020 at 09:42
Resolved 17 August 2020 at 15:39