Auto rotate PDFs generated from PostScript

I’m working on a project that will be receiving PostScript files in from several host systems. The PostScript will need to be converted to PDF. Additionally some of the incoming files will be portrait and some landscape. Unfortunately there will be no externally available indication of what the page orientation will be for each file. So far these requirements can all be easily met in Workflow by using Digital Action plug-in.

My understanding though is that Digital Action plug-in (the venerable Alambic engine of the PlanetPress Imaging module) is considered “legacy” and all reasonable attempts should be made to design new solutions around the Connect engine capabilities instead.

So then, my question is, using the Connect tools is there an easy way to convert PostScript to PDF and do an auto page rotation? I could be missing something, but I wasn’t able to find anything in the Connect Output Presets (which is where I think all the PDF creation options are for Connect).

Or for those of us who like pictures better…

Digital Action or Imaging aren’t legacy plugins. Apart from auto-rotating image output, they are still very relevant today and also enable the creation of image formats such as TIFF, JPEG, VDX, PDF-A, PDF-X…etc while setting image properties such as resolution, compression or downsampling…etc; which can’t currently be done using Connect alone. In addition, they can be used in combination with the Search module to create a true archiving system.

If you are simply interested in rotating the PDF page, the following VBScript will rotate all pages of PDF to portrait in a mixed orientation multipage PDF.

The PDF API is available here.

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

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

Notice that you can get the orientation of pages with:

currentOrientation = myPDF.Pages(x).Orientation

and you can set the orientation with:

myPDF.Pages(x).Orientation = 180

Hence depending on the characteristics of your original PDF, the above script could be reduced to this:

dim myPDF, pageCount, x

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

pageCount = myPDF.Pages.Count

for x = 0 to pageCount-1
        myPDF.Pages(x).Orientation = 0
next
myPDF.Save False

Thanks Rod for setting me straight!

In my case I won’t need to do any scripting because I’m feeding fully composed PostScript to the Digital Action plug-in and just having it figure out the orientation of the pages. That works well. I just wanted to see if there was a similar way to do that with Connect.

To complement Rod’s answer, our solutions have always been about flexibility. There used to be more than one way to do things, and it is still the case with Connect. Yes you can probably solve your issue using a Designer Template. But fear not, Workflow and its toolbox is still an important part of our offering is here to stay (and be improved).