Landscape printing

Helge Blischke h.blischke at acm.org
Fri Jul 29 15:06:18 PDT 2011


Ray Stacey wrote:

>> Ray Stacey wrote:
>>
>> >> Ray Stacey wrote:
>> >>
>> >> >> Ray Stacey wrote:
>> >> >>
>> >> >> >> Ray Stacey wrote:
>> >> >> >>
>> >> >> >> >> Ray Stacey wrote:
>> >> >> >> >>
>> >> >> >> >> > We are running cups 1.4.7 on Solaris 10. I'm trying to
>> >> >> >> >> > print a postscript file from our application using the
>> >> >> >> >> > command lp -o landscape -o PageSize=Legal -d treekill2
>> >> >> >> >> > INV-R200.r01.17206.ps.
>> >> >> >> >> >
>> >> >> >> >> > The file prints on legal paper, however the first page is
>> >> >> >> >> > landscape and each subsequent page is rotated 90 degrees.
>> >> >> >> >> > So the first page is fine, the 5th page is fine, the 9th
>> >> >> >> >> > page is fine ....
>> >> >> >> >> >
>> >> >> >> >> > Any ideas??
>> >> >> >> >>
>> >> >> >> >> What make and model is the printer?
>> >> >> >> >> How is it configured?
>> >> >> >> >> is there a *cupsFilter line in the printer's PPD?
>> >> >> >> >> is there a *LandscapeOrientation: xxxx
>> >> >> >> >> where xxxx is either Plus90 or Minus90 in the PPD?
>> >> >> >> >>
>> >> >> >> >> Helge
>> >> >> >> >>
>> >> >> >> > It's an HP 8100. It is configured using the ppd file from the
>> >> >> >> > cups website. THere is no *cupsFilter and LandscapeOrientation
>> >> >> >> > is Plus90.
>> >> >> >> >
>> >> >> >> > I tried the same command with a generic postscript sample file
>> >> >> >> > and I'm not seeing the rotation problem. That means there is
>> >> >> >> > something wrong with the postscript output from our
>> >> >> >> > application. No idea what it could be, I don't know postscript
>> >> >> >> > language at all.
>> >> >> >>
>> >> >> >> Then post (an URL to) a sample file and do the following:
>> >> >> >> cupsctl --debug-logging
>> >> >> >> print the sample file
>> >> >> >> cupsctl --no-debug-logging
>> >> >> >> post the portion of the /var/log/cups/error_log that contains
>> >> >> >> the messages related to the test job.
>> >> >> >>
>> >> >> >> Helge
>> >> >> >>
>> >> >> > Here you go:
>> >> >> >
>> >> >> > http://home.sourcecable.net/~raystacey/test.ps
>> >> >> >
>> >> >>
>> >> >> Ray,
>> >> >>
>> >> >> your PostScript job itself contains the necessary transformation
>> >> >> for landscape printing, and the contents of each page - including
>> >> >> the showpage execution - is enclosed in a save / restore pair.
>> >> >> Thus, the transformation inserted by cups' pstops filter for
>> >> >> landscape printing acts outside the page contents bracketed by save
>> >> >> and restore what results in every page rotated by 90 degrees with
>> >> >> respect to the previous.
>> >> >>
>> >> >> Please try printing without the "-o landscape" option; I'm pretty
>> >> >> sure you'll get the right printout then.
>> >> >>
>> >> >> Helge
>> >> >>
>> >> > I see what you mean. However, if I print without "-o landscape" it
>> >> > prints in portrait mode. The printout is on legal, but it is not
>> >> > rotated.
>> >>
>> >> Well, can you modify your application to output a PostScript stream as
>> >> indicated by the following context diff output?
>> >>
>> >>>
>> >> If not, I'd suggest to set up a prefilter or similar that does the
>> >> modification.
>> >>
>> >> Helge
>> >>
>> >>
>> >
>> > I made those changes to my test.ps and it printed properly. Can you
>> > explain what the difference is, it's not clear to me?
>>
>> Well, fairly early in the setup section, there is the statement
>>
>> [ 582.0 1008.0 108.0 75.0 12.0 12.0 true 30.0 2.0 0.995000 false true
>> [ false true true true ] init
>>
>> which, in essence, configures the page layout (or the page geometry,
>> whatever you like). The last item in the array (the stuff between the
>> brackets) defines if landscape transformation is to be done or not, and
>> the last statement in the PostScript procedure which makes up the init
>> operator just executes the transformation if specified for the first
>> time, so that it will be active for the first page. For the subsequent
>> pages this transformation is repeated within the newpage procedure.
>>
>> On the other hand, cups' pstops filter inserts the defaults from the PPD
>> preferably just after the %%BeginSetup comment line (or around some other
>> suitable comment line, if the %%BeginSetup is missing).
>> Most of the statements inserted from the PPD defaults call the
>> setpagedevice operator, which resets the graphic state to some extent,
>> espeically reverts to the default coordinate system. That means, the
>> landscape transformation executed by the init procedure preceding the
>> call of setpagedevice is undone by the latter.
>>
>> My proposed modification ensures that the init call is the last statement
>> in the setup section.
>>
>> Helge
>>
>> PS: Note that this modification is not (yet) totally bomb proof. It would
>> be better to (1) delete the statement
>> DoRotate { 0 Hpts translate -90 rotate } if
>> from the init procedure, and
>> (2) insert just after the line
>> /Saveobj save def
>> the statements
>> DoRotate { 0 Hpts translate -90 rotate } if
>> iYpos
>>
>>
>> for the first (and only the first) page.
>>
> 
> I get it now. I will see about our code. I really appreciate your help.
> Thanks!

Here is a version that seems to be "bomp proof", as it even passes though
my heavily modified pstops filter. See the diff:

---snip---
*** test.ps	2011-07-28 23:41:40.000000000 +0200
--- test-ok.ps	2011-07-29 23:56:31.000000000 +0200
***************
*** 2,9 ****
--- 2,11 ----
  %%Title: (atend)
  %%Creator: rstacey (Ray Stacey)
  %%CreationDate: Wed Jul 20 08:07:38 2011
+ %%BoundingBox: 0 0 582 1008
  %%Pages: 9
  %%EndComments
+ %%BeginProlog
  /psfdict 250 dict def
  psfdict begin
  /Psf save def
***************
*** 189,194 ****
--- 191,202 ----
  		iYpos
  		bTEMPLATE
  		showpage
+ 		% DoRotate { 0 Hpts translate -90 rotate } if
+ 		% iYpos
+ 	}
+ 	bind def
+ /beginpage
+ 	{
  		DoRotate { 0 Hpts translate -90 rotate } if
  		iYpos
  	}
***************
*** 234,241 ****
  		/MoPage			SoPage EoPage add 2 div def
  		/MoLine			EoLine SoLine add 2 div def
  		/NoStripes		Vpts SThick div round def
! 		DoRotate { 0 Hpts translate -90 rotate } if
! 		iYpos
  	}
  	bind def
  /pageno_set				%stack: array => -
--- 242,249 ----
  		/MoPage			SoPage EoPage add 2 div def
  		/MoLine			EoLine SoLine add 2 div def
  		/NoStripes		Vpts SThick div round def
! 		% DoRotate { 0 Hpts translate -90 rotate } if
! 		% iYpos
  	}
  	bind def
  /pageno_set				%stack: array => -
***************
*** 419,424 ****
--- 427,434 ----
  stdtemplate
  bHEADER
  } bind def
+ %%EndProlog
+ %%BeginSetup
  [ 582.0 1008.0 108.0 75.0 12.0 12.0 true 30.0 2.0 0.995000 false true false true true true ] init
  /Helvetica findfont
  dup length dict begin
***************
*** 749,755 ****
  399.0 12.0 dYpos l
  0.0 aYpos
  } bind def
! %%EndProlog
  %%Page: 1 1
  %%Key: INVENTORY=000000FA
  %%Key: DEPARTMENT=OPS
--- 759,765 ----
  399.0 12.0 dYpos l
  0.0 aYpos
  } bind def
! %%EndSetup
  %%Page: 1 1
  %%Key: INVENTORY=000000FA
  %%Key: DEPARTMENT=OPS
***************
*** 757,762 ****
--- 767,773 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /Bheader [
  ()
***************
*** 1637,1642 ****
--- 1648,1654 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 2587,2592 ****
--- 2599,2605 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 3537,3542 ****
--- 3550,3556 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 4487,4492 ****
--- 4501,4507 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 5437,5442 ****
--- 5452,5458 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 6387,6392 ****
--- 6403,6409 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 7337,7342 ****
--- 7354,7360 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
***************
*** 8287,8292 ****
--- 8305,8311 ----
  %%Key: BUSINESS_UNIT=TOR
  %%Key: INSTITUTION=LAT
  /Saveobj save def
+ beginpage
  /Title (Traders Inventory Valuation - Current) def
  /bTEMPLATE {
  stdtemplate
---snip---

I have added a %%BoundingBox comment line which prevents the 
pstops filter from complaining about missing bounding box, but as long
as you do not use options like number-up etc., this doesn't really matter.

The main difference to the preceding version is that the landscape
transformation is now executed by the new procedure beginpage.

Helge





More information about the cups mailing list