如何在不另存为 pdf 的情况下从 RDLC 报告中准确打印

How to take accurate print from RDLC report without saving as pdf

我在 rdlc 中以正确的宽度和高度排列文本框以进行预打印页面打印。当我输入 pdf 时,所有标签的对齐方式都是正确的,但我想在不将文件保存为 pdf 的情况下采用相同的方式。 简而言之,我不想使用 pdf,但仍然希望在没有下载文件 getitng 的情况下像 pdf 一样准确打印

enter image description here

我找到了一个解决方案,将报表查看器渲染成pdf,直接在PDF打印中显示

Warning[] warnings;
string[] streamIds;
string contentType;
string encoding;
string extension;

//Export the RDLC Report to Byte Array.
byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out contentType, out encoding, out extension, out streamIds, out warnings);

// Open generated PDF.
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();

参考 https://www.aspsnippets.com/questions/110559/Export-PDF-from-RDLC-Report-and-open-in-Browser-on-Button-Click-using-C-and-VBNet-in-ASPNet/