I'm printing to an impact printer, loaded with 8.5 x 8.5 inch paper. When I print, the printer ejects 11 inches instead of 8.5.
PageMediaSize pageSize = new PageMediaSize(PageMediaSizeName.Unknown, element.Width, element.Height);
PrintDialog dialog = new PrintDialog();
dialog.PrintTicket.PageMediaSize = pageSize;
Console.WriteLine(dialog.PrintableAreaHeight); // 816, good!
dialog.PrintQueue = myQueue; // selected from a combobox
Console.WriteLine(dialog.PrintableAreaHeight); // 1056 :(
dialog.PrintVisual(element, description);
Using "How do I convert Twips to Pixels in .NET?" I've determined that 8.5 inches is 816 pixels, which is the size of my element.Width
and element.Height
. I'm setting a new PageMediaSize
, but this seems to have no effect, dialog.PrintableAreaHeight
is still ends up at 1056 when I set the queue on the dialog.
If I do dialog.ShowDialog()
, manually pick my printer, and manually find and change Paper Size in my printer's advanced settings, then dialog.PrintableAreaHeight
properly reflects the change.
This page http://go4answers.webhost4life.com/Example/set-printdialogs-default-page-size-168976.aspx suggests that I can only set a PageMediaSize
supported by my printer. Using the GetPrintCapabilities
function on my PrintQueue
, I see a list of 10 or so page sizes, none of which are 8.5 x 8.5. This is the same list I see when I go to my printer's advanced settings in windows.