我找到了解决此问题的方法。通过reportviewer设置可能无法更改PDF的dpiX和dpiY,但我们可以通过C#手动导出或渲染pdf来实现。这样做并在其 XMLReport.Render()
的参数中使用 dpiX 和 dpiY 值。<deviceinfo>
这是执行此操作的代码:
string reportype = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
string devinfo = "<DeviceInfo><ColorDepth>32</ColorDepth><DpiX>350</DpiX><DpiY>350</DpiY><OutputFormat>PDF</OutputFormat>"+
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>0.5in</MarginLeft>" +
" <MarginRight>0in</MarginRight>" +
" <MarginBottom>0in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = this.reportViewer1.LocalReport.Render(reportype, devinfo, out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
using (FileStream fs = new FileStream("output3.pdf", FileMode.Create))
{
fs.Write(renderedBytes, 0, renderedBytes.Length);
}