Landscape PS file to Landscape BMP using bmpxxx driver

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

Landscape PS file to Landscape BMP using bmpxxx driver

by Sheri Steeves :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello,

 

I’m trying to convert a postscript file into a Windows bitmap.

When I view the postscript file in GSView it is landscape. When I try to convert the file to a Windows bitmap ( File- Convert, choose –bmpmono) the file created is a rotated (-90 degrees) to a portrait page.

 

Is it possible to get the bitmap in landscape orientation or is the file actually in portrait and shown landscape due to the DCS commands at the top of the ps file? Here is the top of the ps file:

 

%%Creator: PScript5.dll Version 5.2.2

%%CreationDate: 10/1/2010 17:1:10

%%BoundingBox: (atend)

%%Pages: (atend)

%%Orientation: Landscape

%%PageOrder: Special

%%DocumentNeededResources: (atend)

%%DocumentSuppliedResources: (atend)

%%DocumentData: Clean7Bit

%%TargetDevice: (HP LaserJet 8000 Series) (2014.108) 1

%%LanguageLevel: 2

%%EndComments

 

%%BeginDefaults

%%PageBoundingBox: 12 12 599 779

%%ViewingOrientation: 0 1 -1 0

%%EndDefaults

 

Ultimately I want to do this via the command line from a program (using gs_init_args) but I thought I would test this in GSView first.

I’ve tried a few different things in the command line args but no success so far. Here is my command line at this point.

 

gsargv[i++] = "PN" ;             // actual value does not matter

 

sprintf(pBuf, "-I%s;%s", szLibDir, szFontDir );

gsargv[i++] = pBuf ;

 

sprintf(pBuf, "-sFONTPATH=\"%s\"", szFontDir );

gsargv[i++] = pBuf ;

 

// batch mode, don't pause between files            

gsargv[i++] = "-dSAFER" ;       

gsargv[i++] = "-dNOPAUSE" ;            

gsargv[i++] = "-dBATCH" ;

 

gsargv[i++] = "-sDEVICE=bmpmono" ;            

gsargv[i++] = "-dTextAlphaBits=1" ;           

gsargv[i++] = "-dGraphicsAlphaBits=4" ;

 

// Try to keep page as landscape – FAILED

// Seemed to have no effect on test page; That's because this

// argument seems to only apply to pdfwrite and not to bmp devices.

// gsargv[i++] = "-dAutoRotatePages=/PagebyPage" ;

 

// Try setting page size exclusively - FAILED

//gsargv[i++] = "-dFIXEDMEDIA ";

//gsargv[i++] = "-dDEVICEWIDTHPOINTS=792";

//gsargv[i++] = "-dDEVICEHEIGHTPOINTS=612";

 

sprintf(pBuf, "-r%dx%d", dwResolutionX, dwResolutionY ) ;

gsargv[i++] = pBuf ;

 

// Set reader pipe handle

cbNeeded = (strlen("-sOutputFile=%%handle%%") + 12 ) * sizeof (CHAR )  ;       

pBuf = (char *)alloca( cbNeeded ) ;           

memset( pBuf, 0, cbNeeded ) ;          

sprintf(pBuf, "-sOutputFile=%%handle%%%p", m_hGSPipeWriter );

gsargv[i++] = pBuf ;

      

// get ghostscript to send us the bitmap flipped for bottom-up read

gsargv[i++] = "-c";

gsargv[i++] = "<< /Install { 0 currentpagedevice /PageSize get 1 get translate 1 -1 scale } >> setpagedevice";

gsargv[i++] = "-f" ;

 

Thanks for any help you can shed on this issue.

 

 

Best Regards,
Sheri

 


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

Re: Landscape PS file to Landscape BMP using bmpxxx driver

by xirla@gmx.com :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,

I don't know if that is the case, but I had similar problem some times ago and the question was that the mediasize was portrait but the cropBox was landscape. Have you used -dUseCropBox to dircard this ?

>sprintf(pBuf, "-sFONTPATH=\"%s\"", szFontDir );
I think that here yo do not need quotes for the font dir.

>
gsargv[i++] = "-f" ;
After the last -f you don't specify the input file name.

Regards


Al 08/03/2012 21:23, En/na Sheri Steeves ha escrit:

Hello,

 

I’m trying to convert a postscript file into a Windows bitmap.

When I view the postscript file in GSView it is landscape. When I try to convert the file to a Windows bitmap ( File- Convert, choose –bmpmono) the file created is a rotated (-90 degrees) to a portrait page.

 

Is it possible to get the bitmap in landscape orientation or is the file actually in portrait and shown landscape due to the DCS commands at the top of the ps file? Here is the top of the ps file:

 

%%Creator: PScript5.dll Version 5.2.2

%%CreationDate: 10/1/2010 17:1:10

%%BoundingBox: (atend)

%%Pages: (atend)

%%Orientation: Landscape

%%PageOrder: Special

%%DocumentNeededResources: (atend)

%%DocumentSuppliedResources: (atend)

%%DocumentData: Clean7Bit

%%TargetDevice: (HP LaserJet 8000 Series) (2014.108) 1

%%LanguageLevel: 2

%%EndComments

 

%%BeginDefaults

%%PageBoundingBox: 12 12 599 779

%%ViewingOrientation: 0 1 -1 0

%%EndDefaults

 

Ultimately I want to do this via the command line from a program (using gs_init_args) but I thought I would test this in GSView first.

I’ve tried a few different things in the command line args but no success so far. Here is my command line at this point.

 

gsargv[i++] = "PN" ;             // actual value does not matter

 

sprintf(pBuf, "-I%s;%s", szLibDir, szFontDir );

gsargv[i++] = pBuf ;

 

sprintf(pBuf, "-sFONTPATH=\"%s\"", szFontDir );

gsargv[i++] = pBuf ;

 

// batch mode, don't pause between files            

gsargv[i++] = "-dSAFER" ;       

gsargv[i++] = "-dNOPAUSE" ;            

gsargv[i++] = "-dBATCH" ;

 

gsargv[i++] = "-sDEVICE=bmpmono" ;            

gsargv[i++] = "-dTextAlphaBits=1" ;           

gsargv[i++] = "-dGraphicsAlphaBits=4" ;

 

// Try to keep page as landscape – FAILED

// Seemed to have no effect on test page; That's because this

// argument seems to only apply to pdfwrite and not to bmp devices.

// gsargv[i++] = "-dAutoRotatePages=/PagebyPage" ;

 

// Try setting page size exclusively - FAILED

//gsargv[i++] = "-dFIXEDMEDIA ";

//gsargv[i++] = "-dDEVICEWIDTHPOINTS=792";

//gsargv[i++] = "-dDEVICEHEIGHTPOINTS=612";

 

sprintf(pBuf, "-r%dx%d", dwResolutionX, dwResolutionY ) ;

gsargv[i++] = pBuf ;

 

// Set reader pipe handle

cbNeeded = (strlen("-sOutputFile=%%handle%%") + 12 ) * sizeof (CHAR )  ;       

pBuf = (char *)alloca( cbNeeded ) ;           

memset( pBuf, 0, cbNeeded ) ;          

sprintf(pBuf, "-sOutputFile=%%handle%%%p", m_hGSPipeWriter );

gsargv[i++] = pBuf ;

      

// get ghostscript to send us the bitmap flipped for bottom-up read

gsargv[i++] = "-c";

gsargv[i++] = "<< /Install { 0 currentpagedevice /PageSize get 1 get translate 1 -1 scale } >> setpagedevice";

gsargv[i++] = "-f" ;

 

Thanks for any help you can shed on this issue.

 

 

Best Regards,
Sheri

 



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


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

Re: Landscape PS file to Landscape BMP using bmpxxx driver

by Ken Sharp :: Rate this Message:

| View Threaded | Show Only this Message

At 10:03 09/03/2012 +0100, xirla@... wrote:


>I don't know if that is the case, but I had similar problem some times ago
>and the question was that the mediasize was portrait but the cropBox was
>landscape. Have you used -dUseCropBox to dircard this ?

PostScript files don't have CropBox. However, you are basically correct in
your general reasoning I believe.

The DSC comments state 'Landscape' and so a DSC processor (like GSView)
'may' use this and rotate the page. Ghostscript by default doesn't use DSC
comments (they are *comments* and so can be safely ignored).

However it does sound like the job contains a portrait page request (I
can't tell for sure because I don't have the job to look at), despite the
landscape orientation. You can tell Ghostscript to use a specific page size
with the -dFIXEDMEDIA and -dDEVICEWIDTHPOINTS, -dDEVICEHEIGHTPOINTS
switches. See /ghostpdl/gs/doc/Use.htm#Page_parameters

Alternatively you could set -dPROCESSDSC and add PostScript procedures to
deal with the %%Orientation comment.


                 Ken

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

Re: Landscape PS file to Landscape BMP using bmpxxx driver

by xirla@gmx.com :: Rate this Message:

| View Threaded | Show Only this Message

Sorry, I had pdf in mind.

Al 09/03/2012 10:17, En/na Ken Sharp ha escrit:
> At 10:03 09/03/2012 +0100, xirla@... wrote:
>
>
>> I don't know if that is the case, but I had similar problem some
>> times ago and the question was that the mediasize was portrait but
>> the cropBox was landscape. Have you used -dUseCropBox to dircard this ?
>
> PostScript files don't have CropBox. However, you are basically
> correct in your general reasoning I believe.

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

Parent Message unknown Landscape PS file to Landscape BMP using bmpxxx driver

by Sheri Steeves :: Rate this Message:

| View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

>>I don't know if that is the case, but I had similar problem some times ago

>>and the question was that the mediasize was portrait but the cropBox was

>>landscape. Have you used -dUseCropBox to dircard this ?

 

>PostScript files don't have CropBox. However, you are basically correct in

>your general reasoning I believe.

 

>The DSC comments state 'Landscape' and so a DSC processor (like GSView)

>'may' use this and rotate the page. Ghostscript by default doesn't use DSC

>comments (they are *comments* and so can be safely ignored).

 

>However it does sound like the job contains a portrait page request (I

>can't tell for sure because I don't have the job to look at), despite the

>landscape orientation. You can tell Ghostscript to use a specific page size

>with the -dFIXEDMEDIA and -dDEVICEWIDTHPOINTS, -dDEVICEHEIGHTPOINTS

>switches. See /ghostpdl/gs/doc/Use.htm#Page_parameters

 

>Alternatively you could set -dPROCESSDSC and add PostScript procedures to

>deal with the %%Orientation comment.

 

Thanks for all of the responses.

 

I had already tried the –dFIXEDMEDIA and -dDEVICEWIDTHPOINTS, -dDEVICEHEIGHTPOINTS but this had no effect.

 

We have been looking at using the –dPROCESSDSC command. Where would I have to add the Postscript procedures to deal with the %%Orientation comment?

 

We have looked at the gs_dscp.ps file in the \lib folder of the source tree. Is adding this to my args list enough?

 

 

Best Regards,
Sheri


 


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

Parent Message unknown Re: Landscape PS file to Landscape BMP using bmpxxx driver

by Ken Sharp :: Rate this Message:

| View Threaded | Show Only this Message

At 22:53 09/03/2012 +0000, Sheri Steeves wrote:


>I had already tried the dFIXEDMEDIA and -dDEVICEWIDTHPOINTS,
>-dDEVICEHEIGHTPOINTS but this had no effect.

What do you mean by 'had no effect' ? If you altered the page setup then it
should most certainly have had *some* effect, if it didn't then something
is wrong.....


>We have been looking at using the dPROCESSDSC command. Where would I have
>to add the Postscript procedures to deal with the %%Orientation comment?

I have to say that its very hard to be constructive without a (simple!)
example to look at, its not at all clear to me what the construction of the
job is and what effect you are trying to achieve. Very possibly there is a
simple way to do what you want, but since I'm not clear what that is, I
can't think what it would be.

What is it that you are using Ghostscript for ?

Can you please put a simple example file somewhere to look at ?


To answer your question; you need to supply a handler for DSC comments, and
a ProcessDSCComment user parameter.

This needs to be done something like:

/HandleDSC {
...
%% Insert PostScript code here
%% to detect the particular comment
%% and deal with it appropriately
...
} bind def

<<
   /ProcessDSCComment /HandleDSC
 >> setuserparams

The best way to do this is probably in a PostScript file, which you then
feed into Ghostscript on the command line, before the file you actually
want to render.

Please note that in current versions of Ghostscript the file 'gs_dscp.ps'
is not in /ghostpdl/gs/lib but in /ghostpdl/gs/Resource/Init, which
suggests to me you are using an older or forked version of Ghostscript.

The gs_dscp.ps file is part of the internal DSC handling which ends up
using the procedures you supply as above/ You do not (or should not) need
to add it yourselves, it is part of basic Ghostscript.

Please note that I haven't actually tested any of this myself, all the
information here is taken from the Ghostscritp docuemntation.



             Ken

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

Parent Message unknown Re: Landscape PS file to Landscape BMP using bmpxxx driver

by Sheri Steeves :: Rate this Message:

| View Threaded | Show Only this Message

Ken,

Thank you for your answer. It's been a few days since I was able to get back to this issue.

We are trying to convert postscript files to bitmap files using Ghostscript 9.05 and the gs_api functions. Basically we are using the -bmpmono (or other bmpxxx device) and reading the bitmap stream from Ghostscript to later send on to another step in our process.

The postscript files we are converting are being created by printing to a postscript printer and saving to ps file using redmon. When I open this file in GhostView it is displayed as landscape. When I use Ghostview's File-Convert set to bmpmono or other bmpXXX function (or my gs_api_init args command line) the resulting  image is portrait and not landscape. If I create a PDF file from this postscript file the file is landscape when I open it is Adobe Reader.

When I tried to force the page to be landscape by passing -dFIXEDMEDIA, -dDEVIVCEWIDTHPOINTS=792, -dDEVICEHEIGHTPOINTS=612  my resulting bitmap was still in portrait orientation. I checked this by looking at the bitmap header width\height as I was reading in the data stream.  I don't believe this technique would work anyway as we need to be able to handle different page sizes.

What we were looking at doing was seeing if there was some way to have gs send us the bitmap stream already rotated if needed. The key here is if needed as not all of the postscript files have this problem, and we also have to deal with postscript files potentially having mixed media and mixed orientation in the same file.

We are now looking using  -dPROCESSDSC and possibly, as you've said, feeding the ps  file that does the rotation as part of the command line args. The big question is would this apply to the postscript file as a whole or on a page-by-page basis?

Do you have any examples of the postscript I would need to write to do the orientation? Or a link in the right direction?

Here's the sample postscript file that was created for testing. The original file was a landscape document in Word.
https://docs.google.com/open?id=0B7Nhft9xsw0cYVdXdEpkM0ZTM0dyTUVULV82Zmxodw

Here is the current gs_init_args we are using:
gsargv[i++] = "PN" ;            

sprintf(pBuf, "-I%s;%s", szLibDir, szFontDir );
gsargv[i++] = pBuf ;

sprintf(pBuf, "-sFONTPATH=\"%s\"", szFontDir );
gsargv[i++] = pBuf ;

// batch mode, don't pause between files            
gsargv[i++] = "-dSAFER" ;        
gsargv[i++] = "-dNOPAUSE" ;            
gsargv[i++] = "-dBATCH" ;

gsargv[i++] = "-sDEVICE=bmpmono" ;            
gsargv[i++] = "-dTextAlphaBits=1" ;            
gsargv[i++] = "-dGraphicsAlphaBits=4" ;

sprintf(pBuf, "-r%dx%d", dwResolutionX, dwResolutionY ) ;
gsargv[i++] = "pBuf ;

// Set reader pipe handle
cbNeeded = (strlen("-sOutputFile=%%handle%%") + 12 ) * sizeof (CHAR )  ;        
pBuf = (char *)alloca( cbNeeded ) ;            
memset( pBuf, 0, cbNeeded ) ;          
sprintf(pBuf, "-sOutputFile=%%handle%%%p", m_hGSPipeWriter );
gsargv[i++] = pBuf ;
       
// get ghostscript to send us the bitmap flipped for bottom-up read
gsargv[i++] = "-c";
gsargv[i++] = "<< /Install { 0 currentpagedevice /PageSize get 1 get translate 1 -1 scale } >> setpagedevice";
gsargv[i++] = "-f" ;

Best Regards,
Sheri

-----Original Message-----
From: Ken Sharp [mailto:ken.sharp@...]
Sent: March-10-12 4:09 AM
To: Sheri Steeves
Cc: gs-devel@...
Subject: Re: [gs-devel] Landscape PS file to Landscape BMP using bmpxxx driver

At 22:53 09/03/2012 +0000, Sheri Steeves wrote:


>I had already tried the dFIXEDMEDIA and -dDEVICEWIDTHPOINTS,
>-dDEVICEHEIGHTPOINTS but this had no effect.

What do you mean by 'had no effect' ? If you altered the page setup then it should most certainly have had *some* effect, if it didn't then something is wrong.....


>We have been looking at using the dPROCESSDSC command. Where would I
>have to add the Postscript procedures to deal with the %%Orientation comment?

I have to say that its very hard to be constructive without a (simple!) example to look at, its not at all clear to me what the construction of the job is and what effect you are trying to achieve. Very possibly there is a simple way to do what you want, but since I'm not clear what that is, I can't think what it would be.

What is it that you are using Ghostscript for ?

Can you please put a simple example file somewhere to look at ?


To answer your question; you need to supply a handler for DSC comments, and a ProcessDSCComment user parameter.

This needs to be done something like:

/HandleDSC {
...
%% Insert PostScript code here
%% to detect the particular comment
%% and deal with it appropriately
...
} bind def

<<
   /ProcessDSCComment /HandleDSC
 >> setuserparams

The best way to do this is probably in a PostScript file, which you then feed into Ghostscript on the command line, before the file you actually want to render.

Please note that in current versions of Ghostscript the file 'gs_dscp.ps'
is not in /ghostpdl/gs/lib but in /ghostpdl/gs/Resource/Init, which suggests to me you are using an older or forked version of Ghostscript.

The gs_dscp.ps file is part of the internal DSC handling which ends up using the procedures you supply as above/ You do not (or should not) need to add it yourselves, it is part of basic Ghostscript.

Please note that I haven't actually tested any of this myself, all the information here is taken from the Ghostscritp docuemntation.



             Ken

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

Parent Message unknown Re: Landscape PS file to Landscape BMP using bmpxxx driver

by gsview :: Rate this Message:

| View Threaded | Show Only this Message

Sheri,

The attached code adjustA4.ps causes ghostscript to lock the page size to
portrait A4, and if a landscape oriented page is requested will rotate the image
to fit on portrait A4.

You may be able to use modify it to get the outcome you desire.
%!
% This locks the page size to A4 portrait.
% Any A4 landscape pages will be printed rotated on A4 portrait.
<< /Policies << /PageSize 3 >>
   /PageSize [595 842]
   /InputAttributes currentpagedevice /InputAttributes get
     mark exch {1 index /Priority eq not
       {pop << /PageSize [595 842] >>} if
     } forall >>
>> setpagedevice


See also the attached landpdf.ps which attempts to create a PDF file with
correct viewing orientation.

Russell



On 15 Mar 2012 at 20:45, Sheri Steeves wrote:

> Ken,
>
> Thank you for your answer. It's been a few days since I was able to get back to this issue.
>
> We are trying to convert postscript files to bitmap files using Ghostscript 9.05 and the gs_api functions. Basically we are using the -bmpmono (or other bmpxxx device) and reading the bitmap stream from Ghostscript to later send on to another step in our process.
>
> The postscript files we are converting are being created by printing to a postscript printer and saving to ps file using redmon. When I open this file in GhostView it is displayed as landscape. When I use Ghostview's File-Convert set to bmpmono or other bmpXXX function (or my gs_api_init args command line) the resulting  image is portrait and not landscape. If I create a PDF file from this postscript file the file is landscape when I open it is Adobe Reader.
>
> When I tried to force the page to be landscape by passing -dFIXEDMEDIA, -dDEVIVCEWIDTHPOINTS=792, -dDEVICEHEIGHTPOINTS=612  my resulting bitmap was still in portrait orientation. I checked this by looking at the bitmap header width\height as I was reading in the data stream.  I don't believe this technique would work anyway as we need to be able to handle different page sizes.
>
> What we were looking at doing was seeing if there was some way to have gs send us the bitmap stream already rotated if needed. The key here is if needed as not all of the postscript files have this problem, and we also have to deal with postscript files potentially having mixed media and mixed orientation in the same file.
>
> We are now looking using  -dPROCESSDSC and possibly, as you've said, feeding the ps  file that does the rotation as part of the command line args. The big question is would this apply to the postscript file as a whole or on a page-by-page basis?
>
> Do you have any examples of the postscript I would need to write to do the orientation? Or a link in the right direction?
>
> Here's the sample postscript file that was created for testing. The original file was a landscape document in Word.
> https://docs.google.com/open?id=0B7Nhft9xsw0cYVdXdEpkM0ZTM0dyTUVULV82Zmxodw
>
> Here is the current gs_init_args we are using:
> gsargv[i++] = "PN" ;            
>
> sprintf(pBuf, "-I%s;%s", szLibDir, szFontDir );
> gsargv[i++] = pBuf ;
>
> sprintf(pBuf, "-sFONTPATH=\"%s\"", szFontDir );
> gsargv[i++] = pBuf ;
>
> // batch mode, don't pause between files            
> gsargv[i++] = "-dSAFER" ;        
> gsargv[i++] = "-dNOPAUSE" ;            
> gsargv[i++] = "-dBATCH" ;
>
> gsargv[i++] = "-sDEVICE=bmpmono" ;            
> gsargv[i++] = "-dTextAlphaBits=1" ;            
> gsargv[i++] = "-dGraphicsAlphaBits=4" ;
>
> sprintf(pBuf, "-r%dx%d", dwResolutionX, dwResolutionY ) ;
> gsargv[i++] = "pBuf ;
>
> // Set reader pipe handle
> cbNeeded = (strlen("-sOutputFile=%%handle%%") + 12 ) * sizeof (CHAR )  ;        
> pBuf = (char *)alloca( cbNeeded ) ;            
> memset( pBuf, 0, cbNeeded ) ;          
> sprintf(pBuf, "-sOutputFile=%%handle%%%p", m_hGSPipeWriter );
> gsargv[i++] = pBuf ;
>        
> // get ghostscript to send us the bitmap flipped for bottom-up read
> gsargv[i++] = "-c";
> gsargv[i++] = "<< /Install { 0 currentpagedevice /PageSize get 1 get translate 1 -1 scale } >> setpagedevice";
> gsargv[i++] = "-f" ;
>
> Best Regards,
> Sheri
>
> -----Original Message-----
> From: Ken Sharp [mailto:ken.sharp@...]
> Sent: March-10-12 4:09 AM
> To: Sheri Steeves
> Cc: gs-devel@...
> Subject: Re: [gs-devel] Landscape PS file to Landscape BMP using bmpxxx driver
>
> At 22:53 09/03/2012 +0000, Sheri Steeves wrote:
>
>
> >I had already tried the dFIXEDMEDIA and -dDEVICEWIDTHPOINTS,
> >-dDEVICEHEIGHTPOINTS but this had no effect.
>
> What do you mean by 'had no effect' ? If you altered the page setup then it should most certainly have had *some* effect, if it didn't then something is wrong.....
>
>
> >We have been looking at using the dPROCESSDSC command. Where would I
> >have to add the Postscript procedures to deal with the %%Orientation comment?
>
> I have to say that its very hard to be constructive without a (simple!) example to look at, its not at all clear to me what the construction of the job is and what effect you are trying to achieve. Very possibly there is a simple way to do what you want, but since I'm not clear what that is, I can't think what it would be.
>
> What is it that you are using Ghostscript for ?
>
> Can you please put a simple example file somewhere to look at ?
>
>
> To answer your question; you need to supply a handler for DSC comments, and a ProcessDSCComment user parameter.
>
> This needs to be done something like:
>
> /HandleDSC {
> ...
> %% Insert PostScript code here
> %% to detect the particular comment
> %% and deal with it appropriately
> ...
> } bind def
>
> <<
>    /ProcessDSCComment /HandleDSC
>  >> setuserparams
>
> The best way to do this is probably in a PostScript file, which you then feed into Ghostscript on the command line, before the file you actually want to render.
>
> Please note that in current versions of Ghostscript the file 'gs_dscp.ps'
> is not in /ghostpdl/gs/lib but in /ghostpdl/gs/Resource/Init, which suggests to me you are using an older or forked version of Ghostscript.
>
> The gs_dscp.ps file is part of the internal DSC handling which ends up using the procedures you supply as above/ You do not (or should not) need to add it yourselves, it is part of basic Ghostscript.
>
> Please note that I haven't actually tested any of this myself, all the information here is taken from the Ghostscritp docuemntation.
>
>
>
>              Ken
>
> _______________________________________________
> gs-devel mailing list
> gs-devel@...
> http://ghostscript.com/cgi-bin/mailman/listinfo/gs-devel
>



Attachments:
  C:\data\src\ps\adjustA4.ps
  C:\data\src\ps\landpdf.ps
_______________________________________________
gs-devel mailing list
gs-devel@...
http://ghostscript.com/cgi-bin/mailman/listinfo/gs-devel

Parent Message unknown Re: Landscape PS file to Landscape BMP using bmpxxx driver

by Ken Sharp :: Rate this Message:

| View Threaded | Show Only this Message

At 20:45 15/03/2012 +0000, Sheri Steeves wrote:

>The postscript files we are converting are being created by printing to a
>postscript printer and saving to ps file using redmon.

And does the printer have landscape media ?


>When I open this file in GhostView it is displayed as landscape.

Ghostview can (as I mentioned) make use of the %%Orientation comment to do
its own rotation irrespective of Ghostscript.


>When I use Ghostview's File-Convert set to bmpmono or other bmpXXX
>function (or my gs_api_init args command line) the resulting  image is
>portrait and not landscape.

Ghostview just uses Ghostscript behind the scenes, so this is no surprise.


>If I create a PDF file from this postscript file the file is landscape
>when I open it is Adobe Reader.

Ghostscript's pdfwrite device for creating PDF files has a feature (enabled
by default) which looks at the orientation of text on the page and tries to
rotate the page until the text runs top-to-bottom, left-to-right.


>When I tried to force the page to be landscape by passing -dFIXEDMEDIA,
>-dDEVIVCEWIDTHPOINTS=792, -dDEVICEHEIGHTPOINTS=612  my resulting bitmap
>was still in portrait orientation.

OK its important to note that the orientation of the media, and the
orientation of the content, are entirely separate in PostScript.

It seems to me that your printer driver is for a printer which contains
portrait media. As a result the driver has rotated the page content so that
it fits into portrait media, but has placed the %%Orientation comment so
that DSC
consumers (such as Ghostview) can take some additional action. in this case
rotate the output to landscape orientation.

In order to make the bitmap produced by Ghostscript be landscape, you need
to rotate the page *content*. Nothing you do with the media will affect the
orientation of the content.


>What we were looking at doing was seeing if there was some way to have gs
>send us the bitmap stream already rotated if needed. The key here is if
>needed as not all of the postscript files have this problem, and we also
>have to deal with postscript files potentially having mixed media and
>mixed orientation in the same file.
>
>We are now looking using  -dPROCESSDSC and possibly, as you've said,
>feeding the ps  file that does the rotation as part of the command line
>args. The big question is would this apply to the postscript file as a
>whole or on a page-by-page basis?

The answer to that question is 'yes' :-)

The comment handler will be called for every comment, so if each page has a
separate comment it will be invoked for each page. If there is only one
such comment (likely, and may even be specified, I haven't checked) then it
will apply for the whole PostScript job.


>Do you have any examples of the postscript I would need to write to do the
>orientation? Or a link in the right direction?

Sorry,  no. You can start by looking at the PostScript Language Reference
Manual which is available in PDF form from the Adobe web site. The green
and blue books (tutorials) are also available there I believe. You need to
look into the current transformation matrix.


>Here's the sample postscript file that was created for testing. The
>original file was a landscape document in Word.
>https://docs.google.com/open?id=0B7Nhft9xsw0cYVdXdEpkM0ZTM0dyTUVULV82Zmxodw

I can immediately tell that you've used a HP device by the presence of
non-PostScript PJL commands at the start of the file.

Comments then describe the size of the page content:
%%PageBoundingBox: 12 15 582 829

That's llx,lly,urx,ury in PostScript points. You can see this is a portrait
description.

And here's the actual media selection:

%%BeginFeature: *PageSize A4

   <</DeferredMediaSelection true /PageSize [595 842] /ImagingBBox null
/MediaClass null>> setpagedevice


So Ghostscript is giving you a portrait output because that's precisely
what the job asks for.




                 Ken

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

Parent Message unknown Re: Landscape PS file to Landscape BMP using bmpxxx driver

by Ken Sharp :: Rate this Message:

| View Threaded | Show Only this Message

At 13:19 22/03/2012 +0000, Sheri Steeves wrote:

>We did try using -dPROCESSDSC  and was unsuccessful at getting this to
>work at this point.
>
>gsargv[i++] = "-c";
>CStringA postscript = "<< /Install { 0 currentpagedevice /PageSize get 1
>get translate 1 -1 scale } >> setpagedevice " ;
>postscript += "/HandleDSC { (%%ViewingOrientation: 0 1 -1 0) anchorsearch
>{ pop pop <</Orientation 3 index>> setpagedevice  }
>{(%%ViewingOrientation: 1 0 0 1) anchorsearch {pop pop <</Orientation 0
>index>> setpagedevice} {pop} ifelse } ifelse pop } bind def ";
>postscript += "<< /ProcessDSCComment /HandleDSC >> setuserparams " ;
>gsargv[i++] = (LPSTR)(LPCSTR)postscript;
>gsargv[i++] = "-f" ;


You've associated a name object with ProcessDSCComment in setuserparams,
that's not going to do anything because its not executable.

Try :

postscript += "<< /ProcessDSCComment {HandleDSC} >> setuserparams " ;



>Even passing in a simple postscript action of popping values off the stack
>causes Ghostscript to crash:

What do you mean by 'crash' ?

>postscript += "/HandleDSC { pop pop } bind def ";

Well this works OK for me, using {HandleDSC}.



                     Ken

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