-
Notifications
You must be signed in to change notification settings - Fork 30
Description
In the CUPS user interface, you can set a custom paper size by selecting "Custom" for the media size, which adds fields for width and height, and a drop-down for units. When you submit the page, this results in a POST to the /admin endpoint with an OP of set-printer-options, a PageSize of Custom, and fields PageSize.Width, PageSize.Height, and PageSize.Units set to the values you had specified.
The way to customize printer defaults in PyCups seems to be a bit different. You can use cups.Connection.getServerPPD() to fetch a printer PPD, cups.PPD() to instantiate it as an object within Python, call e.g. ppd.setOption('PageSize','w432h576') to select the desired page size, and then pass that PPD object to cups.Connection.addPrinter() to add a new printer with adjusted options. Unfortunately, this doesn't work for custom page sizes; PageSize.Width, PageSize.Height and PageSize.Units don't seem to have any effect when used with cups.PPD.markOption(), and setting PageSize to e.g. Custom.576x432pt (the value that gets stored in the actual PPD for PageSize when you configure things via the CUPS UI) doesn't work either, you end up with the page size set to just Custom, with no actual width or height set.