Skip to main content
Participant
January 20, 2014
Question

how to generate a csv report to determine paper size in a pdf or pdf/a file ?

  • January 20, 2014
  • 1 reply
  • 462 views

how to generate a csv report to determine paper size in a pdf or pdf/a file ?

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
January 22, 2014

Use the cfpdf tag as follows:

<cfpdf

    action = "getinfo"

    name = "pdf_info"

    source = "C:\temp\testFile.pdf">

My Operating System is Windows. This tag gets information about testFile.pdf, and stores it in a structure. I have given this structure the name pdf_info. This structure has the key you are interested in, namely, pageSizes.

Pdf_info.pageSizes is an array whose indices correspond to the respective page number in the PDF. You can use this to generate Comma-Separated Values (CSV) for each page.

<!--- Initialize CSV list --->

<cfset csv = "">

<!--- Add headers or first row, followed by carriage-return --->

<cfset csv = "Page,Height,Width" & chr(13)>

<cfloop from="1" to="#arrayLen(pdf_info.pageSizes)#" index="i">

<cfset row_info = i & "," & pdf_info.pageSizes["height"] & "," & pdf_info.pageSizes["width"] & chr(13)>

<cfset csv = csv & row_info>

</cfloop>

<!--- Output CSV --->

<cfoutput>#csv#</cfoutput>

<!--- Write CSV to file --->

<!--- <cffile action="write" file="C:\temp\output.csv" output="#csv#"> --->

Done!