在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 17:08:58  来源:igfitidea点击:

Setting printer paper size in VB.Net for rdlc report

vb.netprintingreportrdlc

提问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?

我需要为打印机提供自定义纸张尺寸。如何使我的报告具有自定义纸张尺寸?

Link: http://www.uploadmb.com/dw.php?id=1379145264

链接:http: //www.uploadmb.com/dw.php?id=1379145264

回答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"

打开您的报告并右键单击(在灰色窗格上,而不是报告本身)以选择“报告属性”

Report Properties

报告属性

Step 2

第2步

Choose Landscape for your orientation and select a custompaper size. Specify your width and height as well.

为您的方向选择横向并选择自定义纸张尺寸。还要指定您的宽度和高度。

Paper size

纸张尺寸



Programmatically Set PaperSize

以编程方式设置纸张大小

  1. Paper Size should be the size in inches multiplied by 100
  2. Width: The width of the paper, in hundredths of an inch
  3. Height: The height of the paper, in hundredths of an inch
  1. 纸张尺寸应为以英寸为单位的尺寸乘以 100
  2. 宽度:纸张的宽度,以百分之一英寸为单位
  3. 高度:纸张的高度,以百分之一英寸为单位

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")