Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 更改纸张大小_C#_Winforms_Printing_Crystal Reports - Fatal编程技术网

C# 更改纸张大小

C# 更改纸张大小,c#,winforms,printing,crystal-reports,C#,Winforms,Printing,Crystal Reports,如何以编程方式更改打印对话框的纸张大小 我想将纸张大小更改为用户定义的纸张大小,例如:10x12是我的纸张大小 若你们能帮助我如何用10x12的纸张打印水晶报表,那个就更好了 请帮助。尝试以下代码: CRAXDRT.Report report1 = new CRAXDRT.Report(); CRAXDRT.Application app1 = new CRAXDRT.Application(); report1 = app1.OpenReport(@"F:\YourReport.rpt", O

如何以编程方式更改打印对话框的纸张大小

我想将纸张大小更改为用户定义的纸张大小,例如:10x12是我的
纸张大小

若你们能帮助我如何用10x12的纸张打印水晶报表,那个就更好了

请帮助。

尝试以下代码:

CRAXDRT.Report report1 = new CRAXDRT.Report();
CRAXDRT.Application app1 = new CRAXDRT.Application();
report1 = app1.OpenReport(@"F:\YourReport.rpt", OpenReportMethod.OpenReportByDefault);
report1.PaperSize = CRPaperSize.crPaper10x14;

这里有两种改变paper大小的方法。请记住,打印机必须能够处理指定的纸张大小

我们可以使用PrintOptions类设置打印选项。我们应该 打印选项与报告一起使用,因此我们只需设置正在更改的属性

PrintOptions boPrintOptions = boReportClientDocument.PrintOutputController.GetPrintOptions();

        boPrintOptions.DissociatePageSizeAndPrinterPaperSize = false;
        boPrintOptions.DriverName = "my printer driver name";
        boPrintOptions.PageContentHeight = 11;
        boPrintOptions.PageContentWidth = 8;

        PageMargins boPageMargins = new PageMargins();
        boPageMargins.Bottom = 1;
        boPageMargins.Top = 1;
        boPageMargins.Left = 1;
        boPageMargins.Right = 1;

        boPrintOptions.PageMargins = boPageMargins;
        boPrintOptions.PaperOrientation = CrPaperOrientationEnum.crPaperOrientationDefault;
        boPrintOptions.PaperSize = CrPaperSizeEnum.crPaperSizeDefault;
        boPrintOptions.PaperSource = CrPaperSourceEnum.crPaperSourceAuto;
        boPrintOptions.PortName = "";
        boPrintOptions.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexDefault;
        boPrintOptions.PrinterName = @"\\van-s-prt01\VAN-P-OLYMPIA";
一旦我们设置了我们想要的PrintOptions,我们需要使用modify方法来应用这些设置。这些值未经验证,因此在尝试打印时可能会引发异常

boReportClientDocument.PrintOutputController.ModifyPrintOptions(boPrintOptions);
更改打印选项的另一个选项是使用可用的修改方法。它们使用起来更好,因为我们不必获取以前的值,设置我们想要的值,然后使用以前的修改方法,我们可以直接设置我们想要更改的属性。这些测量值以twips为单位。每英寸1440支。使用下面的修改方法时,这些值将被验证,如果该值不可接受或新打印机名称不可用,则将引发异常。此行设置纸张尺寸11英寸高,8英寸宽:

        boReportClientDocument.PrintOutputController.ModifyUserPaperSize((11 * 1440), (8 * 1440));
        boReportClientDocument.PrintOutputController.ModifyPageMargins(1, 1, 1, 1);
        boReportClientDocument.PrintOutputController.ModifyPaperOrientation(CrPaperOrientationEnum.crPaperOrientationLandscape);
        boReportClientDocument.PrintOutputController.ModifyPrinterName(@"\\van-s-prt01\VAN-P-OLYMPIA");

        //Print the report.
        boReportClientDocument.PrintOutputController.PrintReport(null);

有关答案,请参阅本页:


我知道如何将纸张大小设置为预定义的纸张大小bt I wan如何将其设置为用户定义的纸张大小帮助我解决问题