在 VB.Net 中为 rdlc 报告设置打印机纸张大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18799640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting printer paper size in VB.Net for rdlc report
提问by Hamzeh Khater
I built a report with a landscape orientation using VB.net 2010 and made the ??size 16.5 cm * 8.25 cm
我使用 VB.net 2010 构建了一个横向的报告,并将尺寸设为 16.5 cm * 8.25 cm
When you print the report directly shows the size of the page A4 !!!
打印报告时直接显示A4页面大小!!!
I need to provide the printer with a custom paper size. How can I make my report have a custom paper size?
我需要为打印机提供自定义纸张尺寸。如何使我的报告具有自定义纸张尺寸?
回答by Alex
In order to change the default format (A4) of a report, you must change the report properties to accept a custom paper size.
为了更改报告的默认格式 (A4),您必须更改报告属性以接受自定义纸张尺寸。
Set PaperSize By GUI
通过 GUI 设置纸张大小
Step 1
第1步
Open your report and right click (on the gray pane, not the report itself) to select "Report Properties"
打开您的报告并右键单击(在灰色窗格上,而不是报告本身)以选择“报告属性”
Step 2
第2步
Choose Landscape for your orientation and select a custompaper size. Specify your width and height as well.
为您的方向选择横向并选择自定义纸张尺寸。还要指定您的宽度和高度。
Programmatically Set PaperSize
以编程方式设置纸张大小
- Paper Size should be the size in inches multiplied by 100
- Width: The width of the paper, in hundredths of an inch
- Height: The height of the paper, in hundredths of an inch
- 纸张尺寸应为以英寸为单位的尺寸乘以 100
- 宽度:纸张的宽度,以百分之一英寸为单位
- 高度:纸张的高度,以百分之一英寸为单位
Here is the code I used to programmatically set a custom paper size to my report
这是我用来以编程方式为我的报告设置自定义纸张尺寸的代码
ReportViewer1.PrinterSettings.DefaultPageSettings.PaperSize = new PaperSize("Custom", 650, 325)
**Note: Don't forget, you may need to use the code ReportViewer1.RefreshReport()
if it doesn't work.*
**注意:不要忘记,ReportViewer1.RefreshReport()
如果它不起作用,您可能需要使用代码。*
For more information, visit MSDN's PaperSettings.PaperSize page
有关更多信息,请访问MSDN 的 PaperSettings.PaperSize 页面
回答by wael mrabet
I solved the issue by setting the report properties - setting up page size by inches, after that setting up the width 3.0in and height 8.3in the problem is solved.
我通过设置报告属性解决了这个问题 - 按英寸设置页面大小,然后设置宽度 3.0in 和高度 8.3in 问题就解决了。
回答by Irina
Dim page As XmlElement = AddElement(reportSection, "Page", Nothing)
Dim page As XmlElement = AddElement(reportSection, "Page", Nothing)
'landscape
AddElement(page, "PageHeight", "8.5in")
AddElement(page, "PageWidth", "11in")