How do I rotate landscape pages only?

Hi,

I wonder if someone could help.

I have received batches of plain A4 PDF files containing thousands of records. The trouble is that some of the pages in the PDF are landscape. A record in the PDF has three types of pages: summary information could span multiple portrait pages; transaction details mainly contain tables and span multiple landscape pages and terms & conditions which could span two to five portrait pages.

I need to set record boundaries and enhance the statements with logos, barcode and client specific messages.

For the purpose of adding OMR, all pages need to be portrait. Is there a way to auto rotate landscape pages only in the datamapper or designer?

Many thanks,

Steve

Hi Steve,

I’m not sure in Designer or the data mapper. (I would think the latter not though but could be wrong.) But in Workflow you can use a script utilising Alambic API. I’m not a expert with it but looking at another post I modified some code and added it to a run script in Workflow and was able to rotate three pages.

var PDF = Watch.GetPDFEditObject();
PDF.Open(Watch.GetJobFileName(),false);

PDF.Pages(1).Orientation = 270;
PDF.Pages(2).Orientation = 270;
PDF.Pages(3).Orientation = 270;

PDF.Save(true);
PDF.Close();

Note that the first page of my PDF was already portrait so I skipped it and started at the second page which has a index of 1. Some of the other devs here will chime in with there more experience regarding Alambic API.

Hope this helps.

Regards,

S

Hello Sharne,

Thank you for your input and the example script but is there a way to automatically detect only the landscape pages and rotate them? Your example assumes that you already know which pages are landscape. This doesn’t work in my case where I have thousands of pages and landscape pages could be at any indexes within each record.

Many thanks in advance.

Steve

OK, I would definitely use a Run Script in the workflow to preprocess the PDF before using it as a background in the Designer.

Copy and paste the following script in the Run Script action and set the language to VBScript. In this example, all rotated PDF files are saved with their original name in E:\OLForums\156122\tempPDF\. Edit the path to suit your environment.

The next step in your process can be a Folder capture action which grabs the PDF from the above path and pass it to either the Execute Data Mapping or All In One step.

dim myPDF, myRotatedPDF, myRect
dim x, pageHeight, pageWidth, tempright, myRotatedPDFName

myRotatedPDFName = Watch.GetOriginalFileName

Set myPDF = Watch.GetPDFEditObject
myPDF.open Watch.GetJobFileName,false

Set myRotatedPDF = Watch.GetPDFEditObject
myRotatedPDF.create “E:\OLForums\156122\tempPDF\” & myRotatedPDFName

Set myRect = CreateObject(“AlambicEdit.PdfRect”)

for x = 0 to myPDF.Pages.Count-1
Set myRect = myPDF.Pages(x).size
pageWidth = myRect.Right
pageHeight = myRect.Top

    if (pageWidth < pageHeight) then
            myRect.Bottom = 0
            myRect.Left = 0
            myRect.Top = 842      'height in points for A4
            myRect.Right = 595    ' width in 595 points for A4
            myRotatedPDF.Pages.insert x, myRect
            myRotatedPDF.Pages(x).merge2 myPDF.Pages(x),0,0,0,1
    else
            tempright = myRect.Right
            myRect.Right = myRect.Top
            myRect.Top = tempright
            myRotatedPDF.Pages.insert x, myRect
            myRotatedPDF.Pages(x).merge2 myPDF.Pages(x),0,myRect.Top,90,1
    end if

next

myRotatedPDF.save false

The Alambic API documentation is available here:

http://help.objectiflune.com/files/EN/alambicedit-api/AlambicEdit.html

The Watch API documentation is available here:

http://help.objectiflune.com/en/pres-workflow-user-guide/8.5/#Workflow/Scripts/Watch_Object.html

1 Like

Hello Rod,

This is sublime, awesome! It’s exactly what I have been looking for !!!

Thank you very much.

Steve

thanks for this I know this will work but it brings it out of Connect and therefore we have the same old issues with PDF handling with Planet PRess but but all good.

Totally agree, it would be good to have an imposition module with Workflow to work with PDFs. GMC Has this option to impose wothout going through the Inspire Design module…

Hi Rod,

For life of me I cannot remember how to change the input PDF instead of outputting the file to a specific folder. Can you advise how I can use this script to modify the input PDF from the Folder Capture instead of creating a new file?

Regards,

S