Please enable JavaScript to view this site.

A-Shell Reference

The printer init commands PAPERLENGTH and PAPERWIDTH allow you define custom paper sizes, if the driver supports it (which is a big IF!). See related topics PAPERSIZE and Custom Paper Sizes.

PAPERLENGTH = ###

PAPERWIDTH = ###

where ### are tenths of millimeters. Unfortunately, support for this feature varies widely among printer drivers. Some drivers do not support it at all. Others may support it only if you first set the driver default properties to "Custom" or "User defined" page size (which pretty much undermines the value of being able to set it from the software). In other cases, the feature is only supported in the latest version of the printer driver from the manufacturer. (This is a good general rule: whenever there is a problem with a printer, start by downloading the latest driver from the manufacturer website or the Windows update site.)

If you attempt to set the paper length and width, and the driver does not support it, A-Shell will first try to set the paper to the PAPERSIZE value specified in your printer init or print file. (If you didn't specify one, then it will try PAPERSIZE=0.) If after that change, the driver still does not indicate support for individual page length and width, it will try again with PAPERSIZE=CUSTOM (aka 256). Finally if that doesn't work, it will log a trace message (regardless of the TRACE settings) which looks something like:

Custom paper width/length not supported by printer driver!

If you SET TRACE LP ON, you'll get more detailed trace messages showing the individual steps in the process.

For printer drivers that don't support PAPERLENGTH and PAPERWIDTH settings in all modes, the most common workaround is to first set the printer to its "custom" paper size, which may then allow the application to override it with a different custom size. This is why A-Shell tries PAPERSIZE=256 (CUSTOM) automatically.

HOWEVER, some drivers may indicate support for PAPERLENGTH and PAPERWIDTH, but in reality it only works when the printer is first set to CUSTOM. This problem can be detected in the LP TRACE as follows:

DEVMODE Device:Brother HL-5250DN, Ver:793, Size:156, Extra:2360, ...

Requesting paperwidth override to 150.0 mm (5.9 in)

Requesting paperlength override to 140.0 mm (5.5 in)

Updated page size: 5100 x 6600 pixels

...

Final page size: 5100 x 6600 pixels (600 x 600 dpi); print area: 150,100,4950,6500

 

The clue here is that there was no attempt to set the paper size prior to requesting the paperwidth override, combined with the fact that the updated page size (5100 x 6600 pixels at 600 x 600 dpi, or 8.5 x 11 inches) doesn't match the requested size.

In such a case, you should try adding PAPERSIZE=CUSTOM to the printer ini file to see if that resolves the problem, which in the case of this printer, does, as shown in this trace:

DEVMODE Device:Brother HL-5250DN, Ver:793, Size:156, Extra:2360, bin=1, duplex=1, paper=1, orient=1, copies=1, dmFields=0x1ff1f

Requesting papersize #256

Requesting paperwidth override to 150.0 mm (5.9 in)

Requesting paperlength override to 140.0 mm (5.5 in)

Updated page size: 3532 x 3300 pixels

 

For more details and tips, see the A-Shell forum discussion "Custom paper sizes (case study)."

Note that unlike PAPERSIZE, PAPERLENGTH and PAPERWIDTH have no corresponding //GDI commands (primarily because the support for them seems to vary so much between printer drivers that the benefits of a non-printer-specific GDI command seem negligible, at least at the moment.