crystal report customer pagesize

来源:互联网 发布:深圳租房 知乎 编辑:程序博客网 时间:2024/05/22 09:00
Go to Start > Settings > Printers. 
Select File > Server Properties. 
Select Create New Form. 
Type a name for your new form. 
Enter the paper size of your form. You can also enter the margins if applicable. 
Click Ports. Select the port to which the printer is attached. 
Click Drivers. Select the printer driver. 
Click Save Form. 

Return to Crystal Reports. Go to Page Setup. Your new form should be listed in the drop-down list in the Page Options panel. It will set your horizontal and vertical dimensions to the same as you added on your new form. This will also keep the orientation correct (not changing between portrait and landscape). 
setting customer pagesize in code:
C# version:

System.Drawing.Printing.PrintDocument doctoprint = new System.Drawing.Printing.PrintDocument();
            doctoprint.PrinterSettings.PrinterName = "Printer"; //'(ex. "Epson SQ-1170 ESC/P 2")

            for (int i = 0; i < doctoprint.PrinterSettings.PaperSizes.Count - 1; i++)
            {
                int rawKind;
                if (doctoprint.PrinterSettings.PaperSizes[i].PaperName == "72mm x Receipt")
                {
                    rawKind = Convert.ToInt32(doctoprint.PrinterSettings.PaperSizes[i].GetType().GetField("kind", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(doctoprint.PrinterSettings.PaperSizes[i]));
                    //crPrintOut.PrintOptions.PaperSize = rawKind;
                    crPrintOut.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;

                    break;
                }
            }
  • Proposed as answer by deepgags 
0 0
原创粉丝点击