I would like to add custom page sizes to my printer's .ppd (PostScript printer definition) file. What do I have to add to get a new page size working properly?
问题:
回答1:
You have to add values for each additional page size at 4 different places:
- for
PageSize
, - for
PageRegion
, - for
ImageableArea
and - for
PaperDimension
Best, you take one PPD and search for sections enclosed in these keywords
*OpenUI *PaperSize: PickOne
....
*CloseUI *PaperSize
.
*OpenUI *PageSize: PickOne
....
*CloseUI *PageSize
and for the sections starting with
*DefaultImageableArea: ...
.
*DefaultPaperDimension: ...
Use the lines you find in there as templates for your new entries. Note, that dimensions are given in PostScript points (where 72pt == 1inch ~= 2.54cm).
Caveats:
- Add your new lines at each of the 4 places in the PPD.
- Make sure you use uniq names for your new media sizes.
- Make sure you don't have any syntax errors in your PPD.
- Once you're done (or while you're at editing it), check your PPD with the
cupstestppd
utility (available on Linux and on Mac OS X).
Update
Regarding testing the PPD with cupstestppd
:
By default, this will report errors as **FAIL**
even if it finds some "not-so-important" syntax issues (PPD string translations, filters, UIConstraints, profiles, media sizes). You can relax these strict checks a bit and use -W all
in order to report all these as warnings only, not as errors:
cupstestppd -W all /path/to/PPDfile.ppd
If this returns lines saying WARN size ...
you should pay close attention to them and make sure you fix the PPD.
回答2:
I have HP LaserJet 1200. The PPD file provided by the Foomatic/pxlmono driver lacks some standard paper sizes. I updated it with the following statements:
*OpenUI *PageSize/Page Size: PickOne
*FoomaticRIPOption PageSize: enum CmdLine A
*OrderDependency: 100 AnySetup *PageSize
*DefaultPageSize: A4
*PageSize Letter/US Letter: "%% FoomaticRIPOptionSetting: PageSize=Letter"
*FoomaticRIPOptionSetting PageSize=Letter: " -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792"
*End
*PageSize Executive/Executive: "%% FoomaticRIPOptionSetting: PageSize=Executive"
*FoomaticRIPOptionSetting PageSize=Executive: " -dDEVICEWIDTHPOINTS=522 -dDEVICEHEIGHTPOINTS=756"
*End
*PageSize Legal/US Legal: "%% FoomaticRIPOptionSetting: PageSize=Legal"
*FoomaticRIPOptionSetting PageSize=Legal: " -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=1008"
*End
*PageSize A4/A4: "%% FoomaticRIPOptionSetting: PageSize=A4"
*FoomaticRIPOptionSetting PageSize=A4: " -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842"
*End
*PageSize A5/A5: "%% FoomaticRIPOptionSetting: PageSize=A5"
*FoomaticRIPOptionSetting PageSize=A5: " -dDEVICEWIDTHPOINTS=420 -dDEVICEHEIGHTPOINTS=595"
*End
*PageSize A6/A6: "%% FoomaticRIPOptionSetting: PageSize=A6"
*FoomaticRIPOptionSetting PageSize=A6: " -dDEVICEWIDTHPOINTS=298 -dDEVICEHEIGHTPOINTS=420"
*End
*PageSize A7/A7: "%% FoomaticRIPOptionSetting: PageSize=A7"
*FoomaticRIPOptionSetting PageSize=A7: " -dDEVICEWIDTHPOINTS=210 -dDEVICEHEIGHTPOINTS=298"
*End
*PageSize EnvISOB5/Envelope B5: "%% FoomaticRIPOptionSetting: PageSize=EnvISOB5"
*FoomaticRIPOptionSetting PageSize=EnvISOB5: " -dDEVICEWIDTHPOINTS=499 -dDEVICEHEIGHTPOINTS=709"
*End
*PageSize EnvISOB6/Envelope B6: "%% FoomaticRIPOptionSetting: PageSize=EnvISOB6"
*FoomaticRIPOptionSetting PageSize=EnvISOB6: " -dDEVICEWIDTHPOINTS=354 -dDEVICEHEIGHTPOINTS=499"
*End
*PageSize EnvISOB7/Envelope B7: "%% FoomaticRIPOptionSetting: PageSize=EnvISOB7"
*FoomaticRIPOptionSetting PageSize=EnvISOB7: " -dDEVICEWIDTHPOINTS=250 -dDEVICEHEIGHTPOINTS=354"
*End
*PageSize B5/B5 (JIS): "%% FoomaticRIPOptionSetting: PageSize=B5"
*FoomaticRIPOptionSetting PageSize=B5: " -dDEVICEWIDTHPOINTS=516 -dDEVICEHEIGHTPOINTS=729"
*End
*PageSize B6/B6 (JIS): "%% FoomaticRIPOptionSetting: PageSize=B6"
*FoomaticRIPOptionSetting PageSize=B6: " -dDEVICEWIDTHPOINTS=363 -dDEVICEHEIGHTPOINTS=516"
*End
*PageSize B7/B7 (JIS): "%% FoomaticRIPOptionSetting: PageSize=B7"
*FoomaticRIPOptionSetting PageSize=B7: " -dDEVICEWIDTHPOINTS=258 -dDEVICEHEIGHTPOINTS=363"
*End
*PageSize Env10/Envelope #10: "%% FoomaticRIPOptionSetting: PageSize=Env10"
*FoomaticRIPOptionSetting PageSize=Env10: " -dDEVICEWIDTHPOINTS=297 -dDEVICEHEIGHTPOINTS=684"
*End
*PageSize EnvDL/Envelope DL: "%% FoomaticRIPOptionSetting: PageSize=EnvDL"
*FoomaticRIPOptionSetting PageSize=EnvDL: " -dDEVICEWIDTHPOINTS=312 -dDEVICEHEIGHTPOINTS=624"
*End
*PageSize EnvMonarch/Envelope Monarch: "%% FoomaticRIPOptionSetting: PageSize=EnvMonarch"
*FoomaticRIPOptionSetting PageSize=EnvMonarch: " -dDEVICEWIDTHPOINTS=279 -dDEVICEHEIGHTPOINTS=540"
*End
*PageSize EnvC5/Envelope C5: "%% FoomaticRIPOptionSetting: PageSize=EnvC5"
*FoomaticRIPOptionSetting PageSize=EnvC5: " -dDEVICEWIDTHPOINTS=459 -dDEVICEHEIGHTPOINTS=649"
*End
*PageSize EnvC6/Envelope C6: "%% FoomaticRIPOptionSetting: PageSize=EnvC6"
*FoomaticRIPOptionSetting PageSize=EnvC6: " -dDEVICEWIDTHPOINTS=323 -dDEVICEHEIGHTPOINTS=459"
*End
*PageSize EnvC7/Envelope C7: "%% FoomaticRIPOptionSetting: PageSize=EnvC7"
*FoomaticRIPOptionSetting PageSize=EnvC7: " -dDEVICEWIDTHPOINTS=230 -dDEVICEHEIGHTPOINTS=323"
*End
*CloseUI: *PageSize
*OpenUI *PageRegion: PickOne
*OrderDependency: 100 AnySetup *PageRegion
*DefaultPageRegion: A4
*PageRegion Letter/US Letter: "%% FoomaticRIPOptionSetting: PageSize=Letter"
*PageRegion Executive/Executive: "%% FoomaticRIPOptionSetting: PageSize=Executive"
*PageRegion Legal/US Legal: "%% FoomaticRIPOptionSetting: PageSize=Legal"
*PageRegion A4/A4: "%% FoomaticRIPOptionSetting: PageSize=A4"
*PageRegion A5/A5: "%% FoomaticRIPOptionSetting: PageSize=A5"
*PageRegion A6/A6: "%% FoomaticRIPOptionSetting: PageSize=A6"
*PageRegion A7/A7: "%% FoomaticRIPOptionSetting: PageSize=A7"
*PageRegion EnvISOB5/Envelope B5: "%% FoomaticRIPOptionSetting: PageSize=EnvISOB5"
*PageRegion EnvISOB6/Envelope B6: "%% FoomaticRIPOptionSetting: PageSize=EnvISOB6"
*PageRegion EnvISOB7/Envelope B7: "%% FoomaticRIPOptionSetting: PageSize=EnvISOB7"
*PageRegion B5/B5 (JIS): "%% FoomaticRIPOptionSetting: PageSize=B5"
*PageRegion B6/B6 (JIS): "%% FoomaticRIPOptionSetting: PageSize=B6"
*PageRegion B7/B7 (JIS): "%% FoomaticRIPOptionSetting: PageSize=B7"
*PageRegion Env10/Envelope #10: "%% FoomaticRIPOptionSetting: PageSize=Env10"
*PageRegion EnvDL/Envelope DL: "%% FoomaticRIPOptionSetting: PageSize=EnvDL"
*PageRegion EnvMonarch/Envelope Monarch: "%% FoomaticRIPOptionSetting: PageSize=EnvMonarch"
*PageRegion EnvC5/Envelope C5: "%% FoomaticRIPOptionSetting: PageSize=EnvC5"
*PageRegion EnvC6/Envelope C6: "%% FoomaticRIPOptionSetting: PageSize=EnvC6"
*PageRegion EnvC7/Envelope C7: "%% FoomaticRIPOptionSetting: PageSize=EnvC7"
*CloseUI: *PageRegion
*DefaultPaperDimension: A4
*PaperDimension Letter/US Letter: "612 792"
*PaperDimension Executive/Executive: "522 756"
*PaperDimension Legal/US Legal: "612 1008"
*PaperDimension A4/A4: "595 842"
*PaperDimension A5/A5: "420 595"
*PaperDimension A6/A6: "298 420"
*PaperDimension A7/A7: "210 298"
*PaperDimension EnvISOB5/Envelope B5: "499 709"
*PaperDimension EnvISOB6/Envelope B6: "354 499"
*PaperDimension EnvISOB7/Envelope B7: "250 354"
*PaperDimension B5/B5 (JIS): "516 729"
*PaperDimension B6/B6 (JIS): "363 516"
*PaperDimension B7/B7 (JIS): "258 363"
*PaperDimension Env10/Envelope #10: "297 684"
*PaperDimension EnvDL/Envelope DL: "312 624"
*PaperDimension EnvMonarch/Envelope Monarch: "279 540"
*PaperDimension EnvC5/Envelope C5: "459 649"
*PaperDimension EnvC6/Envelope C6: "323 459"
*PaperDimension EnvC7/Envelope C7: "230 323"
*DefaultImageableArea: A4
*ImageableArea Letter/US Letter: "18 36 594 756"
*ImageableArea Executive/Executive: "18 36 504 720"
*ImageableArea Legal/US Legal: "18 36 594 972"
*ImageableArea A4/A4: "18 36 577 806"
*ImageableArea A5/A5: "18 36 402 559"
*ImageableArea A6/A6: "18 36 280 384"
*ImageableArea A7/A7: "18 36 192 262"
*ImageableArea EnvISOB5/Envelope B5: "18 36 481 673"
*ImageableArea EnvISOB6/Envelope B6: "18 36 336 463"
*ImageableArea EnvISOB7/Envelope B7: "18 36 232 318"
*ImageableArea B5/B5 (JIS): "18 36 498 693"
*ImageableArea B6/B6 (JIS): "18 36 345 480"
*ImageableArea B7/B7 (JIS): "18 36 240 327"
*ImageableArea Env10/Envelope #10: "18 36 279 648"
*ImageableArea EnvDL/Envelope DL: "18 36 294 588"
*ImageableArea EnvMonarch/Envelope Monarch: "18 36 261 504"
*ImageableArea EnvC5/Envelope C5: "18 36 441 613"
*ImageableArea EnvC6/Envelope C6: "18 36 305 423"
*ImageableArea EnvC7/Envelope C7: "18 36 212 287"
回答3:
I have a Samsung printer so I downloaded the source code to the SpliX drivers. The driver source includes a Makefile to compile .ppd from sources that list the available page sizes much more succinctly. Now that missing paper size shows up in the print dialog's options.
(That did not solve my problem printing onto small paper. My real problem with custom paper sizes likely has something to do with the way applications talk to cups and the switch from .ps to .pdf as the preferred page input to cups in Ubuntu 9.04...)