- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Visual Studio 2015 社区报告查看器版本 12 在我的 C# 项目中显示 rdlc 报告。这是普通的A4页报告
它在客户端 PC 上适用于 Windows XP、Vista、Win 7,但是当在 Windows 10 64 位上安装相同的应用程序时,我会遇到如下问题
正如您在上图中看到的那样,右侧和底部出现了不必要的边距,字体大小也减小了。但是当我将报告导出为 PDF 时,生成的 PDF 没有问题,它与我设计的报告相同。
我尝试了什么:
打印类代码
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 位 PC 上运行,但在部署到具有 Windows 10 64 位的客户端 PC 上后无法运行
在客户端 PC 上安装 .Net 4.0 框架、SQL Server 2008、Windows 10 64 位
如何解决。
最佳答案
我认为此问题与安装的任何工具无关,或者仅与 Windows 10 64 位有关。
相反,这是 jdweng 和 Reza Aghaei 提到的 DPI 问题。更具体地说,是高 DPI 设备。
不确定您是否注意到,但是您上传的两张图片的像素不同,低像素的图片显示了报告的正确呈现。这可以说支持了由高 DPI 引起的缩放问题的观点。
现在,有很多关于此的文章、帖子和问题。但是,微软支持门户网站上的一个非常接近于为受害者提供某种正确方向的人似乎没有为这种行为提供的可能的解决方案(是的,复数)和解决方法(再次,复数)。
您可以在此处找到这篇文章:https://support.microsoft.com/en-au/help/3025083/windows-scaling-issues-for-high-dpi-devices
我相信,我在下面引用的解决方法暂时可以帮助您。
Change application properties
In Explorer or on the Start menu, right-click the application name, select Properties, select the Compatibility tab, and then select the Disable display scaling on high DPI settings check box.
Note:In Windows 10 Version 1703 and later version of Windows, the text of the Disable display scaling on high DPI settings option is changed to Override high DPI scaling behavior, scaling performed by: Application.
关于c# - Visual Studio 2015 社区报告查看器版本 12 使用 C# 获取额外 margin 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51946537/
我配置了我的RouteInitializer如下: class AppRouteInitializer implements RouteInitializer { init(Router rout
我正在尝试从 Android 应用程序发送短信。我正在使用 PendingIntent 以便我可以使用 Broadcast Receiver 检查它是否发送正常。由于 sendTextMessage
目录 简介 1 "额外"字段是什么 1.1 "额外"是指与业务无关 1.2 产生
应用程序读取 JSON 数据。然后它会将其放入 ListView (正确),但在按下某个项目后,我总是会得到显示的相同值。下面的代码我认为是问题所在,但我找不到。 try{ JSONArray
我正在使用以下代码 (Kotlin) 创建通知 val builder = NotificationCompat.Builder(ctx) ........ .set
我有一个问题。现在我正在使用 3 个面板,mainPanel 和其他 2 个面板(btnPanel 和 iconPanel)。所以问题是当我按下“重置”按钮时,我删除了 iconPanel 并再次添加
这是我的 html: Settings Export Import 和CSS: span.button { float:right; margin-righ
我正在尝试将一个结构编码为 JSON,然后将其插入我的 Mongo 数据库,但不断出现此错误:%!(EXTRA main.Test={575590180 Me})。我究竟做错了什么?我完全从我从事的另
嘿,我遇到了这些 latex 格式问题,有人可以提供一些帮助吗? .tex 文件: \begin{table}{} \renewcommand{\arraystretch}{1.1} \c
我在 FragmentPagerAdapter 中使用了 Fragment 的 ArrayList。 我想在 saveState() 中保存此 ArrayList 的状态,并在 restoreStat
我做了this MapKit-教程 一切正常,但如何为我的 pin 添加额外的属性? 这是我的课车: import Foundation import MapKit class Car: NSObje
关于 Android intent 将提供的附加功能有哪些文档? 更新: 我做了一些进一步的调查。我知道我们可以假设每个 Intent 都不会解析任何数据或额外内容,除非有明确记录。此外,一些(但不是
我在 python3.4.3 上使用 SqlAlchemy 来管理 MySQL 数据库。我正在创建一个表: from datetime import datetime from sqlalchemy
我正在使用 bootstrap 创建网页。我在两个 block (内容和标题)上派生了正文。在内容 block 中,我有 div 类 .container .sameTable 在里面我有 div 类
我在Windows 7上的MinGW和MSYS下使用gfortran构建了一些fortran程序。但是当我在未安装MinGW和MSYS的其他计算机上运行它们时,系统总是要求一些dll,例如libgfo
第一个元素的右侧似乎有额外的间距,我不知道它是从哪里来的。有人可以帮助我吗? 这是我使用的代码: http://jsfiddle.net/srabeat/tenx4y1c/1/ for (i = 0;
我使用 fs-extra 收到以下错误: ERROR { [Error: EPERM: operation not permitted, unlink 'C:\Projects\xxx\branche
我正在尝试在 CBC 模式下使用 AES-128 加密 320 字节的二进制数据,并将密码存储到一个文件中。输出文件应该是 320 字节,但我得到了 336 字节。这是我的代码: #include
我有一个特定的要求,我必须从我的 Activity 中触发浏览器上的 url。我可以使用以下代码执行此操作: Intent browserIntent = new Intent( Intent.A
我正在使用 JMS DI 注入(inject)带有注解的服务: use JMS\DiExtraBundle\Annotation as DI; /** * @DI\Service("foo.bar.
我是一名优秀的程序员,十分优秀!