Tuesday, March 6, 2007

Change Print Paper Size in c# (Pain in the neck)

Hi there,

after struggling with my code for a few hours
i finally made it .. changed the print document size in c#
its unbelievable how hard it is to find info about how to do it

Problem: Set the paper size to A4

the solution was fairly easy:

foreach (PaperSize paperSz in printDocument1.PrinterSettings.PaperSizes)
if (paperSz.PaperName.StartsWith("A4"))
printDocument1.DefaultPageSettings.PaperSize = paperSz;

Hope it will help you
Have a good one

TATA