printviewer_pjobEntry=new printviewer();
dataTable dt=new dataset1.maintabledataTable();
dt.rows.add(“数据集的值”);
_ pjobEntry._rptview.localreport.datasources.add(new reportdatasource(“dataset1”,dt));
_ pjobEntry._rptview.localreport.reportEmbeddedResource=“wainfobussoln.printing.rptsaleinvoice02.rdlc”;
_ pjobEntry.rptView.setDisplayMode(显示模式.printLayout);
_ cWainfoPrintReport.Mexport(PjobEntry.RptView.localReport,true,8.27,11.69,0.25,0.25,0.28,0.25);
< /代码>
但它也和上面描述的一样
在我的电脑上运行的是Windows 10 64位的同一应用程序,但在部署了Windows 10 64位的客户电脑之后,该应用程序无法工作。
在客户端PC.NET 4.0框架上,安装了SQL Server 2008和Windows 10 64位
如何解决问题。
它适用于Windows XP、Vista和Win 7客户端PC,但当相同的应用程序安装在Windows 10 64位上时,我会遇到如下问题

正如你在上面的图片中看到的,有一些不必要的边距来自右边和底端,字体大小也减少了。但当我将报告导出到PDF时,生成的PDF和我设计的报告一样没有问题。
我试过什么:
- 我从安装了Microsoft Report Viewer 2015运行时
https://www.microsoft.com/en-us/download/details.aspx?id=45496
- 已安装Microsoft SQL Server 2014功能包(用于SQL的系统CLR类型)
服务器2014)
- 尝试使用以下代码将RDLC直接导出到打印机
打印类代码
public static class _cWainfoPrintReport
{
private static int m_currentPageIndex;
private static IList<Stream> m_streams;
public static Stream CreateStream(string name,
string fileNameExtension, Encoding encoding,
string mimeType, bool willSeek)
{
Stream stream = new MemoryStream();
m_streams.Add(stream);
return stream;
}
public static void _mExport(LocalReport report, bool print = true, double _pageWightInches = 8.27, double _pageHeightInches = 11.69, double _MarginTopInches = 0.025, double _MarginLeftInches = 0.025, double _MarginRightInches = 0.025, double _MarginBottomInches = 0.025)
{
string deviceInfo =
@"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>" + _pageWightInches + "in</PageWidth> <PageHeight>" + _pageHeightInches + "in</PageHeight> <MarginTop>" + _MarginTopInches + "in</MarginTop> <MarginLeft>" + _MarginLeftInches + "in</MarginLeft> <MarginRight>" + _MarginRightInches + "in</MarginRight> <MarginBottom>" + _MarginBottomInches + "in</MarginBottom> </DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
report.Render("Image", deviceInfo, CreateStream,
out warnings);
foreach (Stream stream in m_streams)
stream.Position = 0;
if (print)
{
_mPrint(_pageWightInches, _pageHeightInches, _MarginTopInches, _MarginLeftInches, _MarginRightInches, _MarginBottomInches);
}
report.ReleaseSandboxAppDomain();
}
// Handler for PrintPageEvents
public static void _mPrintPage(object sender, PrintPageEventArgs ev)
{
Metafile pageImage = new
Metafile(m_streams[m_currentPageIndex]);
// Adjust rectangular area with printer margins.
Rectangle adjustedRect = new Rectangle(
ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
ev.PageBounds.Width,
ev.PageBounds.Height);
// Draw a white background for the report
ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
// Draw the report content
ev.Graphics.DrawImage(pageImage, adjustedRect);
// Prepare for the next page. Make sure we haven't hit the end.
m_currentPageIndex++;
ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
public static PaperSize CalculatePaperSize(double WidthInCentimeters, double HeightInCentimetres)
{
int Width = int.Parse((Math.Round((WidthInCentimeters * 0.393701) * 100, 0, MidpointRounding.AwayFromZero)).ToString());
int Height = int.Parse((Math.Round((HeightInCentimetres * 0.393701) * 100, 0, MidpointRounding.AwayFromZero)).ToString());
PaperSize NewSize = new PaperSize();
NewSize.RawKind = (int)PaperKind.Custom;
NewSize.Width = Width;
NewSize.Height = Height;
NewSize.PaperName = "Letter";
return NewSize;
}
public static void _mPrint(double _pageWightInches = 8.27, double _pageHeightInches = 11.69, double _MarginTopInches = 0.025, double _MarginLeftInches = 0.025, double _MarginRightInches = 0.025, double _MarginBottomInches = 0.025)
{
if (m_streams == null || m_streams.Count == 0)
throw new Exception("Error: no stream to print.");
PrintDocument printDoc = new PrintDocument();
PaperSize RequiredPaperSize = CalculatePaperSize(_pageWightInches * 2.54, _pageHeightInches * 2.54);
bool FoundMatchingPaperSize = false;
for (int index = 0; index < printDoc.PrinterSettings.PaperSizes.Count; index++)
{
if (printDoc.PrinterSettings.PaperSizes[index].Height == RequiredPaperSize.Height && printDoc.PrinterSettings.PaperSizes[index].Width == RequiredPaperSize.Width)
{
printDoc.PrinterSettings.DefaultPageSettings.PaperSize = printDoc.PrinterSettings.PaperSizes[index];
printDoc.DefaultPageSettings.PaperSize = printDoc.PrinterSettings.PaperSizes[index];
FoundMatchingPaperSize = true;
break;
}
}
if (!printDoc.PrinterSettings.IsValid)
{
throw new Exception("Error: cannot find the default printer.");
}
else
{
printDoc.PrintPage += new PrintPageEventHandler(_mPrintPage);
m_currentPageIndex = 0;
printDoc.Print();
}
}
public static void _mPrintToPrinter(this LocalReport report)
{
_mExport(report);
}
public static void _mDisposePrint()
{
if (m_streams != null)
{
foreach (Stream stream in m_streams)
stream.Close();
m_streams = null;
}
}
}
打印按钮上的代码
PrintViewer _PJobEntry = new PrintViewer();
DataTable dt = new DataSet1.MainTableDataTable();
dt.Rows.Add('vales for dataset');
_PJobEntry._RptView.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
_PJobEntry._RptView.LocalReport.ReportEmbeddedResource = "WAINFOBUSSOLN.Printing.RptSaleInvoice02.rdlc";
_PJobEntry._RptView.SetDisplayMode(DisplayMode.PrintLayout);
_cWainfoPrintReport._mExport(_PJobEntry._RptView.LocalReport, true, 8.27, 11.69, 0.25, 0.25, 0.28, 0.25);
但它也和上面描述的一样
在我的电脑上运行的是Windows 10 64位的同一应用程序,但在部署了Windows 10 64位的客户电脑之后,该应用程序无法工作。
如何解决。