How to get predefined paper size by PaperKind

前端 未结 6 2121
迷失自我
迷失自我 2021-02-05 18:10

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 program

6条回答
  •  醉酒成梦
    2021-02-05 19:04

    A LINQ way to achieve your goal is something like this:

    PrinterSettings printerSettings = new PrinterSettings();
    IQueryable paperSizes = printerSettings.PaperSizes.Cast().AsQueryable();
    PaperSize a4rotated = paperSizes.Where(paperSize => paperSize.Kind == PaperKind.A4Rotated).FirstOrDefault();
    

    Good luck!

提交回复
热议问题