Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:26:44+00:00 2026-06-03T06:26:44+00:00

I use Ghostscript to convert PDF documents to PCL for printing. Recently I have

  • 0

I use Ghostscript to convert PDF documents to PCL for printing. Recently I have the additional requirement that all pages must be rotated to Portrait before printing. I have found a way to do so using Ghostscript with following command and postscript function.

"C:\Program Files (x86)\gs\bin\gswin32c.exe" "-dNOPAUSE" "-dNOPROMPT" "-dBATCH" "-sDEVICE=pxlmono" "-Ic:\Program Files (x86)\gs\fonts\;c:\Program Files (x86)\gs\lib\;c:\Program Files (x86)\gs\lib\;" "-r300" "-sOutputFile=C:\EXPORTFILE_e542e04f-5e84-4c8e-9b41-55480cd5ec52.cache" "rotate612x792.ps" "C:\EXPORTFILE_3a5de9da-d9ca-4562-8cb6-10fb8715385a.cache"

Contents of rotate612x792.ps

%! Rotate Pages
<< /Policies << /PageSize 5 >> 
   /PageSize [612 792] 
   /InputAttributes currentpagedevice 
   /InputAttributes get mark exch {1 index /Priority eq not {pop << /PageSize [612 792] >>} if }  forall >>
   >> setpagedevice

The problem is that this function replaces all page sizes with letter size. My documents are sometimes legal or A4. I have tried to modify this function to replace landscape sizes with their portrait counterpart, but have not been able to produce functioning postscript. I need to be pointed in the right direction to produce the postscript equivalent of the following pseudo code.

for(each page)
{
   if(PageSize == [792 612])
       PageSize = [612 792];
}

I am aware that there are non-Ghostscript ways of rotating pages, but if I can get this to work it would fit nicely into my process and would not reduce performance.

Here is a sample of one of my pdf files:
Sample1.pdf

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:26:45+00:00Added an answer on June 3, 2026 at 6:26 am

    I found a workable solution. It is not as versatile as I hoped, but it hits all my requirements.

    The following postscript script will rotate A4, Letter and Legal documents to Portrait. To get it to do other page sizes adjust the min and max sizes.

    %!PS
      %   Sequence to set up for a single page size, auto fit all pages.
      %   Autorotate A4 Letter and Legal page sizes to Portrait
      << /Policies << /PageSize 3 >>
         /InputAttributes currentpagedevice /InputAttributes get    %current dict
         dup { pop 1 index exch undef } forall    % remove all page sizes
         dup 0 << /PageSize [ 595 0 612 99999 ] >> put    % [ min-w min-h max-w max-h ]
      >> setpagedevice
    

    This postscript script will rotate A4, Letter and Legal documents to Landscape. The only difference is the Min/Max page size values.

    %!PS
      %   Sequence to set up for a single page size, auto fit all pages.
      %   Autorotate A4 Letter and Legal page sizes to Landscape
      << /Policies << /PageSize 3 >>
         /InputAttributes currentpagedevice /InputAttributes get    %current dict
         dup { pop 1 index exch undef } forall    % remove all page sizes
         dup 0 << /PageSize [ 0 595 99999 612 ] >> put    % [ min-w min-h max-w max-h ]
      >> setpagedevice
    

    This solution is based off the auto-rotate.ps file I found in the source code for the hylafax project. That project appears to be licensed under BSD.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this Ghostscript command to convert a PDF to images: gs \ -q
I am using GhostScript to generate some thumbnails of PDF pages in an ASP.NET
I'm trying to use ghostscript to convert a .ps file to a series of
I'm trying to use Ghostscript 9.02 on Windows 7 to print a PDF to
I use Ghostscript to strip images from PDF files into jpg and run Tesseract
use case example I have a servlet that is receiving login requests. If a
I'm usually able to use ghostscript to convert PDFs to PNGs with the command:
I'm attempting to use Python to convert a multi-page PDF into a series of
I am attempting to use GhostScript 9.04 with .NET (gsdll32.dll) to convert and then
I'm trying to convert a PDF to a PNG image (at least the cover

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.