自从我将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();
}
使用PaperHeight being 11.69f
和PaperWidth being 8.27f
,ClipBounds being {X = -699050.6 Y = -699050.6 Width = 1398101.25 Height = 1398101.25} System.Drawing.RectangleF
但是,我不能只强调将ActiveReports版本更改为11(现在使用inches
进行信息发布,但预览仍然可以使用。在physscal上打印时输出不会更改)打印机或Bullzip打印机。
有人对此有见识吗?
编辑:
在使用已编写的方法打印报告之前,pdf看起来很完美。
var pdfReportArchiv = new PdfExport();
pdfReportArchiv.Security.Encrypt = encrypt;
pdfReportArchiv.Security.Permissions = PdfPermissions.AllowPrint;
pdfReportArchiv.Security.Use128Bit = true;
pdfReportArchiv.Export(report.Document, pathAndName);
答案 0 :(得分:0)
从7更改为11时,systemPrinter.Graphics.PageUnit = GraphicsUnit.Pixel;
行不再使用并引起了问题。