I need to get paper size by System.Drawing.Printing.PaperKind. Are there any predefined values? I don’t want to hardcode or calculate paper sizes, I just want to get it programmatically. Thanks.
I need to get paper size by System.Drawing.Printing.PaperKind. Are there any predefined values? I
Share
A subset of predefined values can be had by iterating over a
PrinterSettings.PaperSizescollection.Our application has the user select a printer, providing us with a
PrinterSettingsobject. Contained withinPrinterSettingsis a list ofPaperSize‘s supported by the printer – not everything (note that the XPS Document Driver (win7) supports all sizes).In our case this subset of supported sizes is all we need. A user specified
PaperKindis passed to our printing code, and it goes through ourPrinterSettingsobject until it either finds the user’s selection or gives up and uses a default.In the example below you can see that the
PaperSizeobjects are correctly filled.It’s only a subset, but maybe that’s also enough for you. the printing APIs in .NET are really unclear and msdn isn’t really much help… Hopefully it puts you on the right track!