Convert PDF to PS - Automatic page rotation to Portrait

View: New views
4 Messages — Rating Filter:   Alert me  

Convert PDF to PS - Automatic page rotation to Portrait

by Lakos Dániel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Im using Hylafax, which can only send portrait documents,  but  theres a
need  to fax  landscape PDFs as well.
So I need a solution to detect page orientation and rotate the document
to portrait, if its landscape.
Portrait pages should be left alone...

Ive found a solution in the GS archives, and the rotation works as it
should, but some text are malformed/characters missing after conversion.
Does Anybody have an idea whats wrong?
Is there any other method to "auto rotate" pages?
My GhostScript Version is 8.15.

Thank You in Advance,
Daniel

The solution I use, is the following.
-----------------------------------------------------------------------------
gs -sOutputFile=out.ps \
            -sDEVICE=pswrite \
            -dBATCH -dNOPAUSE -dSAFER=true \
            autorotate.ps \
            in.pdf
-----------------------------------------------------------------------------
autorotate.ps:::::
%!PS
  %   Sequence to set up for a single page size, auto fit all pages.
  << /Policies << /PageSize 3 >>
     /InputAttributes currentpagedevice /InputAttributes get    %current
dict
     dup { pop 1 index exch undef } forall    % remove all page sizes
     dup 0 << /PageSize [ 595 842 ] >> put    % for A4 use [ 595 842 ]
  >> setpagedevice
-----------------------------------------------------------------------------
 


_______________________________________________
gs-devel mailing list
gs-devel@...
http://www.ghostscript.com/mailman/listinfo/gs-devel

Re: Convert PDF to PS - Automatic page rotation to Portrait

by Ken Sharp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

At 11:23 07/11/2009 +0100, =?ISO-8859-2?Q?Lakos_D=E1niel?= wrote:

>Ive found a solution in the GS archives, and the rotation works as it
>should, but some text are malformed/characters missing after conversion.
>Does Anybody have an idea whats wrong?
>Is there any other method to "auto rotate" pages?
>My GhostScript Version is 8.15.

First suggestion, upgrade to something more recent. The current version is
8.70 and 8.15 is quite old.

You might also consider using ps2write instead of pswrite as ps2write
generally does a better job.

By the way, the code you are using only auto-rotates pages if they are
landscape letter (842x595 points), other page sizes may be scaled and/or
centered.

             Ken
_______________________________________________
gs-devel mailing list
gs-devel@...
http://www.ghostscript.com/mailman/listinfo/gs-devel

Re: Convert PDF to PS - Automatic page rotation to Portrait

by Lakos Dániel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ken Sharp írta:

> At 11:23 07/11/2009 +0100, =?ISO-8859-2?Q?Lakos_D=E1niel?= wrote:
>
>> Ive found a solution in the GS archives, and the rotation works as it
>> should, but some text are malformed/characters missing after conversion.
>> Does Anybody have an idea whats wrong?
>> Is there any other method to "auto rotate" pages?
>> My GhostScript Version is 8.15.
>
> First suggestion, upgrade to something more recent. The current
> version is 8.70 and 8.15 is quite old.
>
> You might also consider using ps2write instead of pswrite as ps2write
> generally does a better job.
>
> By the way, the code you are using only auto-rotates pages if they are
> landscape letter (842x595 points), other page sizes may be scaled
> and/or centered.
>
>             Ken
>
>
>
Thank you for taking time to answer.

I upgraded to 8.70.
with '-sDevice=pswrite' the output page size is correct A4 (8.26 x 11.69 inches) -- characters and page size are OK.
using '-sDevice=ps2write' the output 8.50 x 11.00 inches -- charachters ar ok, but the document doesnt fit

As I know the 842x592 points are correct for A4 papersize.  

It seems that the code i using (device=pswrite) is correctly convert the pdf to ps (checked using adobe distiller).
When Hylafax conerts this PS to Tiff, things go wrong.

How to get ps2write working with the correct papersize?
I hope the output of ps2write is going to give better results when converted to tiff.

_______________________________________________
gs-devel mailing list
gs-devel@...
http://www.ghostscript.com/mailman/listinfo/gs-devel

Re: Convert PDF to PS - Automatic page rotation to Portrait

by Ken Sharp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

At 13:21 07/11/2009 +0100, Lakos Dániel wrote:


>with '-sDevice=pswrite' the output page size is correct A4 (8.26 x 11.69
>inches) -- characters and page size are OK.

Yes, sorry I meant A4, no letter previously.


>using '-sDevice=ps2write' the output 8.50 x 11.00 inches -- charachters ar
>ok, but the document doesnt fit

8.5x11 is Letter size.


>It seems that the code i using (device=pswrite) is correctly convert the
>pdf to ps (checked using adobe distiller).
>When Hylafax conerts this PS to Tiff, things go wrong.

Goes wrong how ? Can you run the produced PostScript file back through
Ghostscript, and the output is correct ?

You can have Ghostscript create a TIFF file for you if that's all you want,
and you can do it from the original PDF.


>How to get ps2write working with the correct papersize?
>I hope the output of ps2write is going to give better results when
>converted to tiff.

Sounds like your system may be defaulting to letter media.
You could try -sPAPERSIZE=a4 -dFIXEDMEDIA also -sDEFAULTPAPERSIZE=a4


                 Ken
_______________________________________________
gs-devel mailing list
gs-devel@...
http://www.ghostscript.com/mailman/listinfo/gs-devel