I am using the PDF Converter v2.50f and am having a problem creating a PDF that uses a custom paper size. Note that I am using "normal" Windows printing code - i.e. using the DEVMODE structure to specify the printer settings and then using StartDoc/StartPage/EndPage/EndDoc to generate the file.
Some of the documents I use require a custom paper size, and according to the MSDN, you can achieve this by specifying zero as the dmPaperSize member, and use the dmPaperLength and dmPaperWidth members to specify the custom size in tenths of a millimetre. However, when I do with with PDF Converter, it doesn't work and I end up with a PDF that is 0.04 inches wide and 0.04 inches tall.
Any ideas how I can overcome this problem?
Custom paper sizes via DEVMODE
OK, I figured it out. You need to ensure the DM_PAPERLENGTH and DM_PAPERWIDTH flags are set in the DEVMODE dmFields member, e.g.:
pDevMode->dmPaperLength = CUSTOM_HEIGHT;
pDevMode->dmPaperWidth = CUSTOM_WIDTH;
pDevMode->dmPaperSize = 0;
pDevMode->dmFields |= DM_PAPERLENGTH|DM_PAPERWIDTH;
I have used custom paper sizes with physical printers before, without having to set these flags, but this doesn't seem to to any harm (the MSDN seems to hint that dmFields indicates what flags the driver supports, and I haven't seen code that sets this explicitly before).
pDevMode->dmPaperLength = CUSTOM_HEIGHT;
pDevMode->dmPaperWidth = CUSTOM_WIDTH;
pDevMode->dmPaperSize = 0;
pDevMode->dmFields |= DM_PAPERLENGTH|DM_PAPERWIDTH;
I have used custom paper sizes with physical printers before, without having to set these flags, but this doesn't seem to to any harm (the MSDN seems to hint that dmFields indicates what flags the driver supports, and I haven't seen code that sets this explicitly before).
-
- Posts: 46
- Joined: Fri Nov 18 2005
- Location: Nova Scotia
Custom paper size
Wouldn't you want to specify
pDevMode->dmPaperSize = DMPAPER_USER ?
pDevMode->dmPaperSize = DMPAPER_USER ?
Re: Custom paper size
According to the MSDN that ships with VS2005:sprezzatura wrote:Wouldn't you want to specify
pDevMode->dmPaperSize = DMPAPER_USER ?
"dmPaperSize
For printer devices only, selects the size of the paper to print on. This member can be set to zero if the length and width of the paper are both set by the dmPaperLength and dmPaperWidth members. Otherwise, the dmPaperSize member can be set to one of the following predefined values. "
Though I have also seen other documents on the web that mention DMPAPER_USER.