1
votes

Working on a custom printer driver ...

I am having trouble getting some applications (like Microsoft Word, others) to recognize custom paper size.

The vendor paper sizes are shown, but in custom applications the "customsize" option doesn't show up at all

enter image description here

In Word, I see the Custom Page Size - but attempting to print, there are a series of warnings about the page margins:

enter image description hereenter image description here

......

And when printing, the custom size documents are sent to one of the defined sizes.

The gpd (assume 100 dpi):

*Feature: PaperSize
{
    *rcNameID: =PAPER_SIZE_DISPLAY
    *DefaultOption: Size_2x4
    *Option: Size_2x4
    {
        *Name: "2 x 4"
        *PageDimensions: PAIR(200, 400)
        *PrintableArea: PAIR(200, 400)
        *PrintableOrigin: PAIR(0, 0)
    }
    *Option: Size_4x4
    {
        *Name: "4 x 4"
        *PageDimensions: PAIR(400, 400)
        *PrintableArea: PAIR(400, 400)
        *PrintableOrigin: PAIR(0, 0)
    }
    *Option: Size_4x6
    {
        *Name: "4 x 6"
        *PageDimensions: PAIR(400, 600)
        *PrintableArea: PAIR(400, 600)
        *PrintableOrigin: PAIR(0, 0)
    }
    *Option: CUSTOMSIZE
    {
        *rcNameID: =USER_DEFINED_SIZE_DISPLAY
        *MinSize: PAIR(40, 40)
        *MaxSize: PAIR(1200, 3000) 
        *MaxPrintableWidth: 3000
        *MinLeftMargin: 0
        *TopMargin: 0
        *BottomMargin: 0
        *CenterPrintable?: TRUE
        *CursorOrigin: PAIR(0, 0)        
    }
}

The only one item that is missing is the *Command - In Microsoft examples :

*Command: CmdSelect
{
    *Order: DOC_SETUP.13
    *Cmd: "<1B>&l101a8c1e63F<1B>*p0x0Y<1B>*c0t12456x8184Y"
}

Unfortunately the custom printer I make this for has a different printer language that doesn't include page setup commands. So - since I have no command to give, it would make sense not to include a command. I have experimented with changing cursor position for portrait vs landscape, but it does not give good results.

Am I correct in my assumption that, if the gpd is correct, the application will send custom size info without the "Custom" option being available and selectable by the user ? I just can't see anything else I can do to fix the gpd...

I assumed that since these are standard sections, UI plugin does not need to create them specifically... If that assumption is wrong, what would be needed in a OEM UI plugin to make this section show ?

1
Those commands look like HP PCL escape sequences. I'm sure you can find some documentation somewhere.Mark Ransom
You are correct, and I was looking for the wrong information ... Unfortunately, once I found some nice manuals for different style printers, that explain the Cmd in Microsoft example, I also found that I cannot use them... Something else must be wrong.Thalia

1 Answers

2
votes

It appears that Word tries to be "helpful" by determining the paper sizes supported by your printer. Then, Word will try to force the document to fit what it thinks are the supported dimensions by tweaking margins and page sizes. It does this by examining the paper sizes defined in your GPD. Only standard and vendor-defined paper sizes are analyzed; CUSTOMSIZE definitions appear to be totally ignored. In Word 2013, at least, the default *PaperSize option makes a difference too. For example, I defined a larger paper size in my GPD, but it was ignored until I made it the default option.

Keep in mind that Word has a maximum supported page size of 22"x22" [link]. Vendor-defined paper sizes can be larger than this, but those were not displayed in Word's list of page size options. In this case, however, Word still accepted specifying a custom page size up to my larger, but unlisted, vendor-defined paper size without imposing margins.

If having the paper size show up in Word is critical, you may have to experiment to see what Word will accept. I found the limit to acceptable vendor-defined paper sizes to be ~4.04"x~20.04" for my printer driver. Sizes greater than this were absent from Word's list of page sizes.

While diagnosing this issue, I found that Word 2013 refreshes its printer-dependent list of page sizes each time you change printers. Based on that observation, I was able to use the following procedure to experiment with accepted paper sizes:

  1. Open the installed GPD at C:\Windows\System32\spool\drivers\<platform>\3 in a program with Admin Rights.
  2. Start Word.
  3. Open test document.
  4. File > Print.
  5. Select your printer.
  6. Check listed page sizes.
  7. Adjust the *PageDimensions and *PrintableArea values for a vendor-defined paper size in the GPD you opened in step 1.
  8. Save the GPD file.
  9. Select a different printer in Word.

Repeat steps 5-9 until the paper size shows up in Word's list of page sizes.