Fixes and changes on the "cups" output device of Ghostscript -Please Test!
Hi,
I have done several fixes and enhancements on the CUPS Raster output device of Ghostscript, to support the Duplex-related keywords in the CUPS PPD extensions (all tests done with Mike Sweet's "rasterview"):
*cupsFlipDuplex:
----------------
Did not work for landscape documents. In general, the XY and YX components of the matrix were swapped. This broke the output with asymmetric resolutions (like 300x600 dpi) and back sides which are supposed to be rotated or Y-flipped came out blank.
*cupsBackSide:
--------------
Introduced support for this keyword which is the replacement for *cupsFlipDuplex:. Therefore *cupsFlipDuplex: gets generally ignored if *cupsBackSide: is supplied. All modes described in the PPD extensions are supported.
*cupsEvenDuplex:
----------------
Introduced support for this keyword. Now "*cupsEvenDuplex: True" causes a blank page to be appended to documents with odd numbers of pages.
All these changes I have committed to the SVN repository of Ghostscript and so they get part of GPL Ghostscript 8.65.
I have also created patches for Ghostscript 8.64 and uploaded them to
http://www.openprinting.org/download/printing/ghostscript-cups-patches/
The patches are
cups-device-support-cupsbackside-ppd-keyword.patch cups-device-support-cupsevenduplex-ppd-keyword.patch
The first patch also contains the fixes for the *cupsFlipDuplex: keyword.
In addition, I have added support for having page size entries in the PPD which have the same width and height but differ only by the margins, like "A4" with normal margins and "A4.fullbleed" with zero margins. The fix is also uploaded to the SVN repository for Ghostscript 8.65 and the patch for 8.64 is this one:
cups-device-select-pagesize-margins-by-pagesize-name.patch
at the same place as the other two patches.
I will look into the "*APDuplexRequiresFlippedMargin:" keyword soon.
Please have a look into the patches and try them out. Tell me whether they are OK and if something does not work, please supply fixes orhelp me to fix it.
Thanks in advance.
Till
Here is the second part of my fixes and changes.
This time I have added support for the "APDuplexRequiresFlippedMargin" PPD keyword as described on in the "Mac OS X Attributes" section of
http://cups.org/documentation.php/doc-1.4/spec-ppd.html
I have also fixed the margin handling. By testing with a document with gray background, a PPD with 4 different unprintable borders for the 4 edges of the paper, and rasterview I have seen that the printout did not always get gray up to the unprintable borders. There were often wider white borders than necessary. Now I have checked with all duplex/portrait/landscape settings that the background will really fill up the page as much as the printer allows. This is naturally also valid for any graphical element in the document to be printed. Now we get always the best possible results for objects near the borders. In addition, the content should be accurately positioned on the page (not slightly shifted).
I have committed the changes again to the SVN repository of Ghostscript, so that they will make it into GPL Ghostscript 8.65.
Here is a patch containing ALL my changes (also of the first part) on gdevcups.c:
Please apply this patch to an unpatched Ghostscript 8.64. Or take the complete file"and replace cups/gdevcups.c in the Ghostscript source with it:
http://www.openprinting.org/download/printing/ghostscript-cups-patches/gdevcups.c
Please test it. Now all duplex issues when developing CUPS Raster drivers should get solved.
Till
Quoted 48 lines · Till Kamppeter
Hi,
I have done several fixes and enhancements on the CUPS Raster output device of Ghostscript, to support the Duplex-related keywords in the CUPS PPD extensions (all tests done with Mike Sweet's "rasterview"):
*cupsFlipDuplex:
----------------Did not work for landscape documents. In general, the XY and YX components of the matrix were swapped. This broke the output with asymmetric resolutions (like 300x600 dpi) and back sides which are supposed to be rotated or Y-flipped came out blank.
*cupsBackSide:
--------------Introduced support for this keyword which is the replacement for *cupsFlipDuplex:. Therefore *cupsFlipDuplex: gets generally ignored if *cupsBackSide: is supplied. All modes described in the PPD extensions are supported.
*cupsEvenDuplex:
----------------Introduced support for this keyword. Now "*cupsEvenDuplex: True" causes a blank page to be appended to documents with odd numbers of pages.
All these changes I have committed to the SVN repository of Ghostscript and so they get part of GPL Ghostscript 8.65.
I have also created patches for Ghostscript 8.64 and uploaded them to
http://www.openprinting.org/download/printing/ghostscript-cups-patches/
The patches are
cups-device-support-cupsbackside-ppd-keyword.patch cups-device-support-cupsevenduplex-ppd-keyword.patch
The first patch also contains the fixes for the *cupsFlipDuplex: keyword.
In addition, I have added support for having page size entries in the PPD which have the same width and height but differ only by the margins, like "A4" with normal margins and "A4.fullbleed" with zero margins. The fix is also uploaded to the SVN repository for Ghostscript 8.65 and the patch for 8.64 is this one:
cups-device-select-pagesize-margins-by-pagesize-name.patch
at the same place as the other two patches.
I will look into the "*APDuplexRequiresFlippedMargin:" keyword soon.
Please have a look into the patches and try them out. Tell me whether they are OK and if something does not work, please supply fixes orhelp me to fix it.
Thanks in advance.
Till
I did a little correction on my changes, both in the Ghostscript SVN repositories and in the patch for Ghostscript 8.64 which I have uploaded:
The "*cupsEvenDuplex:" PPD keyword is already treated by the pstops and the pdftopdf CUPS filters, so it should not get treated again by Ghostscript's CUPS Raster device. So I have removed the appropriate changes.
Olease re-download the patch
or the modified source file
http://www.openprinting.org/download/printing/ghostscript-cups-patches/gdevcups.c
for Ghostscript 8.64 or update your Ghostscript 8.65 snapshot from the SVN repository.
Till
Quoted 76 lines · Till Kamppeter
Here is the second part of my fixes and changes.
This time I have added support for the "APDuplexRequiresFlippedMargin" PPD keyword as described on in the "Mac OS X Attributes" section of
http://cups.org/documentation.php/doc-1.4/spec-ppd.html
I have also fixed the margin handling. By testing with a document with gray background, a PPD with 4 different unprintable borders for the 4 edges of the paper, and rasterview I have seen that the printout did not always get gray up to the unprintable borders. There were often wider white borders than necessary. Now I have checked with all duplex/portrait/landscape settings that the background will really fill up the page as much as the printer allows. This is naturally also valid for any graphical element in the document to be printed. Now we get always the best possible results for objects near the borders. In addition, the content should be accurately positioned on the page (not slightly shifted).
I have committed the changes again to the SVN repository of Ghostscript, so that they will make it into GPL Ghostscript 8.65.
Here is a patch containing ALL my changes (also of the first part) on
gdevcups.c:Please apply this patch to an unpatched Ghostscript 8.64. Or take the complete file"and replace
cups/gdevcups.cin the Ghostscript source with it:http://www.openprinting.org/download/printing/ghostscript-cups-patches/gdevcups.c
Please test it. Now all duplex issues when developing CUPS Raster drivers should get solved.
Till
Quoted 48 lines · Till Kamppeter
Hi,
I have done several fixes and enhancements on the CUPS Raster output device of Ghostscript, to support the Duplex-related keywords in the CUPS PPD extensions (all tests done with Mike Sweet's "rasterview"):
*cupsFlipDuplex:
----------------Did not work for landscape documents. In general, the XY and YX components of the matrix were swapped. This broke the output with asymmetric resolutions (like 300x600 dpi) and back sides which are supposed to be rotated or Y-flipped came out blank.
*cupsBackSide:
--------------Introduced support for this keyword which is the replacement for *cupsFlipDuplex:. Therefore *cupsFlipDuplex: gets generally ignored if *cupsBackSide: is supplied. All modes described in the PPD extensions are supported.
*cupsEvenDuplex:
----------------Introduced support for this keyword. Now "*cupsEvenDuplex: True" causes a blank page to be appended to documents with odd numbers of pages.
All these changes I have committed to the SVN repository of Ghostscript and so they get part of GPL Ghostscript 8.65.
I have also created patches for Ghostscript 8.64 and uploaded them to
http://www.openprinting.org/download/printing/ghostscript-cups-patches/
The patches are
cups-device-support-cupsbackside-ppd-keyword.patch cups-device-support-cupsevenduplex-ppd-keyword.patch
The first patch also contains the fixes for the *cupsFlipDuplex: keyword.
In addition, I have added support for having page size entries in the PPD which have the same width and height but differ only by the margins, like "A4" with normal margins and "A4.fullbleed" with zero margins. The fix is also uploaded to the SVN repository for Ghostscript 8.65 and the patch for 8.64 is this one:
cups-device-select-pagesize-margins-by-pagesize-name.patch
at the same place as the other two patches.
I will look into the "*APDuplexRequiresFlippedMargin:" keyword soon.
Please have a look into the patches and try them out. Tell me whether they are OK and if something does not work, please supply fixes orhelp me to fix it.
Thanks in advance.
Till
A message that is not in the archive (sent off-list or not yet received): DD6046532A44F047ACD45225E9D737B14A3FB6653D@GVW1155EXB.americas.hpqcorp.net
Quoted 1 line · David
Sorry I have not been able to test your patch yet, but *cupsEvenDuplex worked for me with gpl ghostscript 8.63 when testing hplip 3.9.4.
Thank you for the hint. I have removed the *cupsEvenDuplex handling from the CUPS Raster output device again as it is already done by pstops and pdftopdf.
I have announced the new patch in an earlier e-mail.
Till
A message that is not in the archive (sent off-list or not yet received): DD6046532A44F047ACD45225E9D737B14A40FFAF0E@GVW1155EXB.americas.hpqcorp.net
Quoted 5 lines · David
Till,
I applied your patch to ghostscript 8.64. After testing your patch with a fullbleed 4x6 paper size it looks like the paper size and printable area are not calculated correctly. The same full bleed test works ok with ghostscript 8.62.I have attached the test PPD and CUPS
error_log(s)for reference. Note the CUPS's ImagingBoundingBox was "ImaginBoundingBox = [ 9 9 289 433 ]" when it should be "ImaginBoundingBox = [0 0 298 442 ]".
How did you tell to CUPS that the job is fullbleed? The PPD has non-zero borders for all paper sizes.
It seems also that pstoraster or pstops does not supply something useful for the "cu[psPageSizeName", as error_log shows the following:
D [15/May/2009:14:39:26 -0700] [Job 383] Setting cupsPageSizeName to "74%%BeginFeature: *PageRegion 10074^D^D^D%%BeginSetup%%EndProlog%%EndResource%rom%Resource/IdiomSet/*/*"...
The name is important to distinguish page sizes with the same dimensions but different margins.
Quoted 3 lines
Looking at the fullbleed-bad.txt error log it looks like
gdevcups.chas mistakenly declared this a custom paper size instead of the fullbleed 4x6 paper size and thus uses the custom paper size printable margins of "margins[] = [ 0.125 0.125 0.125 0.125 ]" instead of [ 0 0 0 0 ].Your patch worked ok with the normal "Letter" paper size.
Try something like
*DefaultPageSize: LetterDuplex
*PageSize Letter/Letter 8.5x11in: "<</PageSize[612 792]/ImagingBBox null/cupsPageSizeName(Letter)>>setpagedevice" *PageSize LetterDuplex/Letter AutoDuplex 8.5x11in: "<</PageSize[612 783]/ImagingBBox null/cupsPageSizeName(LetterDuplex)>>setpagedevice" **PageSize A4/A4 210x297mm: "<</PageSize[595 842]/ImagingBBox null/cupsPageSizeName(A4)>>setpagedevice"
*PageSize A4Duplex/A4 AutoDuplex 210x297mm: "<</PageSize[595 833]/ImagingBBox null/cupsPageSizeName(A4Duplex)>>setpagedevice" *PageSize Legal/Legal 8.5x14in: "<</PageSize[612 1008]/ImagingBBox null/cupsPageSizeName(Legal)>>setpagedevice" *PageSize Photo/Photo 4x6in: "<</PageSize[288 432]/ImagingBBox null/cupsPageSizeName(Photo)>>setpagedevice" *PageSize PhotoFullbleed/Photo 4x6in borderless: "<</PageSize[288 432]/ImagingBBox null/cupsPageSizeName(PhotoFullbleed)>>setpagedevice" *PageSize Photo5x7/Photo 5x7in: "<</PageSize[360 504]/ImagingBBox null/cupsPageSizeName(Photo5x7)>>setpagedevice"
...
*CloseUI: *PageSize
...
*DefaultImageableArea: LetterDuplex
*ImageableArea Letter/Letter 8.5x11in: "18.00 36.00 594.00 783.00" *ImageableArea LetterDuplex/Letter AutoDuplex 8.5x11in: "18.00 27.00 594.00 747.00" *ImageableArea A4/A4 210x297mm: "10.00 36.00 585.00 833.00" *ImageableArea A4Duplex/A4 AutoDuplex 210x297mm: "10.00 27.00 585.00 797.00" *ImageableArea Legal/Legal 8.5x14in: "18.00 36.00 594.00 999.00" *ImageableArea Photo/Photo 4x6in: "9.00 9.00 279.00 423.00" *ImageableArea PhotoFullbleed/Photo 4x6in: "0.00 0.00 288.00 432.00" *ImageableArea Photo5x7/Photo 5x7in: "9.00 36.00 351.00 495.00"
...
This should work.
Till
A message that is not in the archive (sent off-list or not yet received): DD6046532A44F047ACD45225E9D737B14A40FFAF11@GVW1155EXB.americas.hpqcorp.net
Thank you, now I see what you want to do.
I have found a bug in gdevcups.c though. There was no protection against cupsPageSizeName getting an invalid value if it does not get set anywhere. Now the value is checked whether it is in the PPD file and if not, it is deleted.
Till
Quoted 59 lines · David
Sorry, I sent you the wrong test PPD.
-dave
Quoted 55 lines
-----Original Message-----
From: Till Kamppeter [mailto:[email protected]] Sent: Tuesday, May 19, 2009 11:45 AM
To: Suffield, David
Cc: Michael Sweet; Yie, Shiyun; [email protected]; gs-devel; Cauligi, Raghothama S
Subject: Re: Fixes and changes on the "cups" output device of Ghostscript -Please Test!Quoted 2 lines · David
Till,
I applied your patch to ghostscript 8.64. After testingyour patch with a fullbleed 4x6 paper size it looks like the paper size and printable area are not calculated correctly. The same full bleed test works ok with ghostscript 8.62.
Quoted 1 line
I have attached the test PPD and CUPS
error_log(s)forreference. Note the CUPS's ImagingBoundingBox was "ImaginBoundingBox = [ 9 9 289 433 ]" when it should be "ImaginBoundingBox = [0 0 298 442 ]". How did you tell to CUPS that the job is fullbleed? The PPD has non-zero borders for all paper sizes.
It seems also that pstoraster or pstops does not supply something useful for the "cu[psPageSizeName", as
error_logshows the following:D [15/May/2009:14:39:26 -0700] [Job 383] Setting cupsPageSizeName to "74%%BeginFeature: *PageRegion 10074^D^D^D%%BeginSetup%%EndProlog%%EndResource%rom%Resource/I diomSet/*/*"...
The name is important to distinguish page sizes with the same dimensions but different margins.
Quoted 1 line
Looking at the fullbleed-bad.txt error log it looks like
gdevcups.chas mistakenly declared this a custom paper size instead of the fullbleed 4x6 paper size and thus uses the custom paper size printable margins of "margins[] = [ 0.125 0.125 0.125 0.125 ]" instead of [ 0 0 0 0 ].Quoted 1 line
Your patch worked ok with the normal "Letter" paper size.
Try something like
*DefaultPageSize: LetterDuplex
*PageSize Letter/Letter 8.5x11in: "<</PageSize[612 792]/ImagingBBox null/cupsPageSizeName(Letter)>>setpagedevice" *PageSize LetterDuplex/Letter AutoDuplex 8.5x11in: "<</PageSize[612 783]/ImagingBBox null/cupsPageSizeName(LetterDuplex)>>setpagedevice" **PageSize A4/A4 210x297mm: "<</PageSize[595 842]/ImagingBBox null/cupsPageSizeName(A4)>>setpagedevice"
*PageSize A4Duplex/A4 AutoDuplex 210x297mm: "<</PageSize[595 833]/ImagingBBox null/cupsPageSizeName(A4Duplex)>>setpagedevice" *PageSize Legal/Legal 8.5x14in: "<</PageSize[612 1008]/ImagingBBox null/cupsPageSizeName(Legal)>>setpagedevice" *PageSize Photo/Photo 4x6in: "<</PageSize[288 432]/ImagingBBox null/cupsPageSizeName(Photo)>>setpagedevice" *PageSize PhotoFullbleed/Photo 4x6in borderless: "<</PageSize[288 432]/ImagingBBox null/cupsPageSizeName(PhotoFullbleed)>>setpagedevice" *PageSize Photo5x7/Photo 5x7in: "<</PageSize[360 504]/ImagingBBox null/cupsPageSizeName(Photo5x7)>>setpagedevice"
...
*CloseUI: *PageSize...
*DefaultImageableArea: LetterDuplex
*ImageableArea Letter/Letter 8.5x11in: "18.00 36.00 594.00 783.00" *ImageableArea LetterDuplex/Letter AutoDuplex 8.5x11in: "18.00 27.00 594.00 747.00" *ImageableArea A4/A4 210x297mm: "10.00 36.00 585.00 833.00" *ImageableArea A4Duplex/A4 AutoDuplex 210x297mm: "10.00 27.00 585.00 797.00" *ImageableArea Legal/Legal 8.5x14in: "18.00 36.00 594.00 999.00" *ImageableArea Photo/Photo 4x6in: "9.00 9.00 279.00 423.00" *ImageableArea PhotoFullbleed/Photo 4x6in: "0.00 0.00 288.00 432.00" *ImageableArea Photo5x7/Photo 5x7in: "9.00 36.00 351.00 495.00"
...This should work.
Till
I have fixed the problem now in the SVN of Ghostscript (rev 9747). Or apply the corrected patch:
See the fix iteself below.
Till
----------------------------------------------------------------------
gdevcups.c +21 -1
@@ -378,7 +378,7 @@/* cupsString */ "" ,/* cupsMarkerType */ "" ,/* cupsRenderingIntent */ - "Letter" /* cupsPageSizeName */ + "" /* cupsPageSizeName */#endif /* CUPS_RASTER_SYNCv1 */ },0 /* landscape */
@@ -2798,6 +2798,7 @@float swap;int xflip =0 , yflip =0 ; +int found =0 ;dprintf2 ("DEBUG2: cups_put_params(%p, %p)\n" , pdev, plist);
@@ -3071,7 +3072,26 @@ yflip =0 ; } +#ifdef CUPS_RASTER_SYNCv1/* +* Chack whether cupsPageSizeName has a valid value +*/ + +if (strlen (cups->header.cupsPageSizeName) !=0 ) { + found =0 ; +for (i = cupsPPD->num_sizes, size = cupsPPD->sizes; + i >0 ; + i --, size ++) +if (strcasecmp (cups->header.cupsPageSizeName, size->name) ==0 ) { + found =1 ; +break ; + } +if (found ==0 ) cups->header.cupsPageSizeName[0 ] ='\0' ; + } +dprintf1 ("DEBUG2: cups->header.cupsPageSizeName = %s\n" , cups->header.cupsPageSizeName); +#endif + +/* * Find the matching page size... */
Quoted 59 lines · David
Sorry, I sent you the wrong test PPD.
-dave
Quoted 55 lines
-----Original Message-----
From: Till Kamppeter [mailto:[email protected]] Sent: Tuesday, May 19, 2009 11:45 AM
To: Suffield, David
Cc: Michael Sweet; Yie, Shiyun; [email protected]; gs-devel; Cauligi, Raghothama S
Subject: Re: Fixes and changes on the "cups" output device of Ghostscript -Please Test!Quoted 2 lines · David
Till,
I applied your patch to ghostscript 8.64. After testingyour patch with a fullbleed 4x6 paper size it looks like the paper size and printable area are not calculated correctly. The same full bleed test works ok with ghostscript 8.62.
Quoted 1 line
I have attached the test PPD and CUPS
error_log(s)forreference. Note the CUPS's ImagingBoundingBox was "ImaginBoundingBox = [ 9 9 289 433 ]" when it should be "ImaginBoundingBox = [0 0 298 442 ]". How did you tell to CUPS that the job is fullbleed? The PPD has non-zero borders for all paper sizes.
It seems also that pstoraster or pstops does not supply something useful for the "cu[psPageSizeName", as
error_logshows the following:D [15/May/2009:14:39:26 -0700] [Job 383] Setting cupsPageSizeName to "74%%BeginFeature: *PageRegion 10074^D^D^D%%BeginSetup%%EndProlog%%EndResource%rom%Resource/I diomSet/*/*"...
The name is important to distinguish page sizes with the same dimensions but different margins.
Quoted 1 line
Looking at the fullbleed-bad.txt error log it looks like
gdevcups.chas mistakenly declared this a custom paper size instead of the fullbleed 4x6 paper size and thus uses the custom paper size printable margins of "margins[] = [ 0.125 0.125 0.125 0.125 ]" instead of [ 0 0 0 0 ].Quoted 1 line
Your patch worked ok with the normal "Letter" paper size.
Try something like
*DefaultPageSize: LetterDuplex
*PageSize Letter/Letter 8.5x11in: "<</PageSize[612 792]/ImagingBBox null/cupsPageSizeName(Letter)>>setpagedevice" *PageSize LetterDuplex/Letter AutoDuplex 8.5x11in: "<</PageSize[612 783]/ImagingBBox null/cupsPageSizeName(LetterDuplex)>>setpagedevice" **PageSize A4/A4 210x297mm: "<</PageSize[595 842]/ImagingBBox null/cupsPageSizeName(A4)>>setpagedevice"
*PageSize A4Duplex/A4 AutoDuplex 210x297mm: "<</PageSize[595 833]/ImagingBBox null/cupsPageSizeName(A4Duplex)>>setpagedevice" *PageSize Legal/Legal 8.5x14in: "<</PageSize[612 1008]/ImagingBBox null/cupsPageSizeName(Legal)>>setpagedevice" *PageSize Photo/Photo 4x6in: "<</PageSize[288 432]/ImagingBBox null/cupsPageSizeName(Photo)>>setpagedevice" *PageSize PhotoFullbleed/Photo 4x6in borderless: "<</PageSize[288 432]/ImagingBBox null/cupsPageSizeName(PhotoFullbleed)>>setpagedevice" *PageSize Photo5x7/Photo 5x7in: "<</PageSize[360 504]/ImagingBBox null/cupsPageSizeName(Photo5x7)>>setpagedevice"
...
*CloseUI: *PageSize...
*DefaultImageableArea: LetterDuplex
*ImageableArea Letter/Letter 8.5x11in: "18.00 36.00 594.00 783.00" *ImageableArea LetterDuplex/Letter AutoDuplex 8.5x11in: "18.00 27.00 594.00 747.00" *ImageableArea A4/A4 210x297mm: "10.00 36.00 585.00 833.00" *ImageableArea A4Duplex/A4 AutoDuplex 210x297mm: "10.00 27.00 585.00 797.00" *ImageableArea Legal/Legal 8.5x14in: "18.00 36.00 594.00 999.00" *ImageableArea Photo/Photo 4x6in: "9.00 9.00 279.00 423.00" *ImageableArea PhotoFullbleed/Photo 4x6in: "0.00 0.00 288.00 432.00" *ImageableArea Photo5x7/Photo 5x7in: "9.00 36.00 351.00 495.00"
...This should work.
Till