OL Learn

Page Size within workflow


Is there a way to get the page size of a PDF from within a workflow script using Java? Need to go through all pages in a document and check if they are landscape or portrait



You may be can get by the return value of the code below.
like true: Portrait, false: landscape

var myPdf = Watch.GetPDFEditObject();
myPdf.Open(Watch.GetJobFilename(), false);

var pdfRect = myPdf.Pages(0).Size();
var pageWidth = pdfRect.right - pdfRect.left ;
var pageHeight = pdfRect.top - pdfRect.Bottom;
if(pageHeight > pageWidth){
Script.ReturnValue = 1;
Script.ReturnValue = 0;}


Can you get the number of pages and then loop through each page to check? Basically we need to rotate any landscape pages to portrait


Hi @jbeal84,

You would like to loop through each page of your document to check if it’s Portrait or Landscape oriented and to rotate the page if it’s a Landscape oriented page, isn’t it? Because in that case you can make use of the JavaScript code shared by @Phil via the following OL Learn forum post: ‘Rotating PDF pages prior to Datamapping’

Please let us know if this is the solution where you’re looking for.