Jeremy Davis
Jeremy Davis
Sitecore, C# and web development
Article printed from:

Pesky Paper for PDF Printers

Why can't I pick a custom size?

Published 25 April 2022
Windows Printing ~4 min. read

Recently I needed to do an odd bit of printing. I needed to generate an A3 PDF for printing which had crop marks around it. That means it needs to be printed to "a bit larger than A3" size. In the past I'd used Foxit's PDF printer for this (where it just worked), but that no longer seems to be free. Turns out the default Windows PDF printer needs a bit of hackery to enable using odd-sized paper. I'm sure I'll find myself needing to do this again in the future, so this is a reminder for my future self.

The problem

I've got a Photoshop drawing that's a "just over A3" sized. It's an A3 print with what printers call "bleed" - the extra bit of your design you have to leave around the edges of a print to ensure that once it's cropped to its right size, the printing goes all the way to the edges of the page. The print company I'm using needs a PDF with crop marks on the image so they can print that extra and trim then trim the artwork to the right size. But when I try to send image this to Microsoft's Windows 10 PDF printer, I can't select a custom paper size, and the choices don't include anything larger than A3:

Print properties, with fixed set of sizes

Now in theory, you should be able to add new paper sizes to printers. There's a UI option in the "Printers & Scanners" page in settings, for "Print server properties":

The 'Printers & scanners' dialog

And in there, you should be able to create new "custom" paper sizes:

Adding a new paper size

And those should then be able to show up in the paper choices. You can see the new option in some print drivers installed on my computer:

New paper size in a LaserJet driver

But it doesn't work with Microsoft's PDF Printer - the larger paper sizes I tried to add would never shows up there.

The solution

After a load of "standard Windows trouble-shooting" (you know: rebooting and reinstalling stuff) I did a pile of googling. That eventually lead me to this blog post about adding custom paper sizes to the MS PDF printer.

The instructions there provided the outline of what I needed to do. Broadly that's:

  • Look in the registry to find some data about the PDF Printer driver
  • Use that data to find some special files on disk which describe the printer
  • Edit one of those files to add some extra data that enables custom paper sizes

Sounds way more complex than it should be - but achievable. However, there were a couple of tricky points for me here.

First up was understanding how the registry data maps to the disk data. The key thing here is that there's actually two things to look at in the registry. First is under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\Print\Printers\Microsoft Print to PDF. There's an entry here that tells you which folder to look in for the print driver data under C:\Windows\System32\spool\V4Dirs. All the folders are named with GUIDs, so you need to know which one to open:

Finding the right folder for the print driver files

But then you need to look at a second bit of data under ...\Microsoft Print to PDF\PrinterDriverData in the registry, in order to find the name of the individual data file to edit. It's also given a fairly random looking name, so would be hard to guess. But the registry item, combined with the blog post saying it's a gpd file gives you the info:

Finding the right file in the print driver folder

Having worked that out, I was able to follow the instructions in the blog about editing the file I'd found. But it didn't work for me, and it took some time for me to work out why...

It turns out the issue is actually pretty simple. The article describes addings some extra markup to the printer definition, which allows the print driver to see the custom paper sizes defined in the "Print server properties" dialog from earlier. It suggests you add following text into the file immediately after the *DefaultOption: entry:

*MinSize: PAIR(936000, 1332000)
*MaxSize: PAIR(5346000, 7560000)
*MaxPrintableWidth: 5346000


But, as highlighted, the mark-up defined here gives some bounds for the "size" of your printer.

What I missed initially is that you have to make sure that you set these to be larger than your desired paper size. Otherwise the print driver will (sensibly) filter out the choices you've defined which "don't fit" on its maximum paper size. That doesn't really make sense for a "print to PDF" driver because it should have no physical limits. But it does make sense for the base abstraction all print drivers are built around, as that assumes that physical paper size is a key property of printers.

Now I should probably have taken the time to work out what the units above actually mean, but to be honest it all looked a bit complex, so I just hacked it. I increased the most significant digit of each of the width & height fields by one to make the maximum larger. And the after a bit more confusion where this sort-of worked but not quite, I realised that you also need to increase the MaxPrintableWidth property too:

*MinSize: PAIR(936000, 1332000)
*MaxSize: PAIR(6346000, 8560000)
*MaxPrintableWidth: 8560000


If you don't change that value to match the largest dimension of your paper, you end up with "unprintable" areas because the printer thinks it can't actually draw on that bit of the paper. That shows up as "hatched" areas in the print preview dialog.

But as soon as those changes are saved, the new size appears in my printer options:

New paper size showing up in the PDF printer

And I can generate my PDFs successfully, on "a bit bigger than A3" paper, to allow for cropping.

After all that I have to echo the writer of the blog post linked above - why don't Microsoft ship this extra config by default? Seems like "print to any sized PDF" would be a sensbible feature. And it would save us all the hacking above...

↑ Back to top