Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.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#打印机只打印约1/6页的报告_C#_Printing_Configuration_Activereports_Page Layout - Fatal编程技术网

C#打印机只打印约1/6页的报告

C#打印机只打印约1/6页的报告,c#,printing,configuration,activereports,page-layout,C#,Printing,Configuration,Activereports,Page Layout,自从我将ActiveReports从7版升级到11版以来,报告的打印位置大约为页面的1/6,布局怪异,只有图片打印正确 但很明显,这只是在打印时,而不是预览时。虽然看起来很奇怪,但我认为问题出在SystemPrinter对象上。 据我所知,这个对象是正确定义的 // get printer if (systemPrinter == null) { systemPrinter = new SystemPrinter { PrinterName = systemPrinterName };

自从我将ActiveReports从7版升级到11版以来,报告的打印位置大约为页面的1/6,布局怪异,只有图片打印正确
但很明显,这只是在打印时,而不是预览时。虽然看起来很奇怪,但我认为问题出在
SystemPrinter
对象上。
据我所知,这个对象是正确定义的

// get printer
if (systemPrinter == null)
{
    systemPrinter = new SystemPrinter { PrinterName = systemPrinterName };
    systemPrinter.StartJob("My-printjob");
}

// set paper source and size
SetPaper(systemPrinter, systemPrinterPaperSource);

// set draw size
var internalOffSetX = systemPrinter.PhysicalOffsetX / systemPrinter.Graphics.DpiX;
var internalOffSetY = systemPrinter.PhysicalOffsetY / systemPrinter.Graphics.DpiY;

internalOffSetX = internalOffSetX - (offSetX / 2.54f);
internalOffSetY = internalOffSetY - (offSetY / 2.54f);

var printWidth = (systemPrinter.PaperSize.Width / 100f) - internalOffSetX;
var printHight = (systemPrinter.PaperSize.Height / 100f) - internalOffSetY;

// Scale: A4 (printable)
var smlOut = RectangleF.FromLTRB(-internalOffSetX, -internalOffSetY, printWidth, printHight);

systemPrinter.Graphics.PageUnit = GraphicsUnit.Pixel;

//Important edit for StackOverflow: Just added this line and the pdf looks perfect
SaveDocumentAsPdf(@"C:\Temp\SaveAsPDF\mydocument.pdf", report);

foreach (Page page in report.Document.Pages)
{
    systemPrinter.StartPage();
    page.Draw(systemPrinter.Graphics, smlOut);
    systemPrinter.EndPage();
}
纸张高度为11.69f
纸张宽度为8.27f
时,
剪贴簿为{X=-699050.6y=-699050.6width=1398101.25height=1398101.25}系统。绘图。矩形
然而,我无法强调的是,我只将ActiveReports版本更改为11(现在使用
英寸
进行测量,但预览仍然正常。在phyiscal打印机或bullzip打印机上打印时,输出不会改变。
有人对此有所了解吗?

编辑:
在使用已经编写好的方法打印报告之前,pdf看起来非常完美

var pdfReportArchiv = new PdfExport();
pdfReportArchiv.Security.Encrypt = encrypt;
pdfReportArchiv.Security.Permissions = PdfPermissions.AllowPrint;
pdfReportArchiv.Security.Use128Bit = true;
pdfReportArchiv.Export(report.Document, pathAndName);

从7更改为11后,行
systemPrinter.Graphics.PageUnit=GraphicsUnit.Pixel;
显然不再使用,导致了问题