How to get predefined paper size by PaperKind

前端 未结 6 2124
迷失自我
迷失自我 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 18:53

    public static PaperSize GetPaperSize(string Name)
        {
            PaperSize size1 = null;
            Name=Name.ToUpper();
            PrinterSettings settings = new PrinterSettings();
            foreach (PaperSize size in settings.PaperSizes)
                if (size.Kind.ToString().ToUpper() == Name)
                {
                    size1 = size;
                    break;
                }
            return size1;            
        }
    

提交回复
热议问题