如何在 C# 中以 A4 大小打印客户端报告定义文件 (.rdlc)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19425008/
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-08-10 14:57:48  来源:igfitidea点击:

How to print Client Report Definition file (.rdlc) on A4 size in C#?

c#reportviewerrdlc

提问by Jsing han

I am trying to print a report using C# Report Viewer Control.

我正在尝试使用 C# 报告查看器控件打印报告。

By the way, I bumped into a problem.

顺便说一下,我遇到了一个问题。

I wanted my .rdlcfile to be printed on A4 size. so I changed .rdlcfile size with A4 size 210X297(mm) in the VS2010 designer. But the report viewer object that uses this .rdlcfile automatically sets the margins on the paper. So the total size of the paper that will be printed was over A4 size.

我希望我的.rdlc文件以 A4 尺寸打印。所以我.rdlcVS2010 设计器中用 A4 尺寸 210X297(mm)更改了文件大小。但是使用此.rdlc文件的报表查看器对象会自动设置纸张上的边距。因此,将打印的纸张的总尺寸超过 A4 尺寸。

I can't estimate the size of the margin. Is there any way to estimate or control the size of the margin?

我无法估计边距的大小。有没有办法估计或控制保证金的大小?

I have been searching for the last some days... I need help. please give me a hand.

最近几天我一直在寻找……我需要帮助。请帮我一把。

My platform is VS2010 / .Net 4.0 / C#

我的平台是 VS2010 / .Net 4.0 / C#



Thanks tezzo for your help. I appriciate it. My problem was which I didn't know the fact that Report > Report properties > Page setup exists. I could resolve my problem by your advice. But I had what makes me confused. so I leave some aditional pictures. I hope it is helpful to another person who encounters such a problem.

感谢 tezzo 的帮助。我很欣赏它。我的问题是我不知道报告 > 报告属性 > 页面设置存在的事实。我可以根据你的建议解决我的问题。但我有什么让我感到困惑。所以我留下了一些额外的图片。我希望它对另一个遇到此类问题的人有所帮助。

  1. You have to click the point that the picture 1 expresses by the check sign. If you click the point that the picture 2 expresses by the check sign, you can not see such a properties window that have a Margins and a PageSize Property, which makes me confused.
  1. 您必须单击图 1 所表示的复选标记点。如果点击图2中对勾所表示的点,就看不到这样一个有Margins和PageSize属性的属性窗口,搞得我一头雾水。

When you reach here, you can follow tezzo's advice. then you can print rdlc file on A4 size.

当你到达这里时,你可以听从 tezzo 的建议。然后您可以在 A4 尺寸上打印 rdlc 文件。

I am first to write here. so I can't add any picture on it. I link pictures.

我先写到这里。所以我不能在上面添加任何图片。我链接图片。

< picture 1>

<图片1>

enter image description here

在此处输入图片说明

< picture 2 >

<图2>

enter image description here

在此处输入图片说明

采纳答案by tezzo

You can set paper size and margins in Report > Report properties > Page setup.

您可以在报告 > 报告属性 > 页面设置中设置纸张大小和边距。

I usually use this settings:

我通常使用这个设置:

  • paper size: A4
  • size: 21 x 29,7 (landscape: 29,7 x 21)
  • left/right margin: 1,3cm
  • bottom/top margins: 1,5cm
  • 纸张尺寸:A4
  • 尺寸:21 x 29,7(横向:29,7 x 21)
  • 左/右页边距:1,3cm
  • 底部/顶部边距:1,5cm

So the maximum width of report will be:

所以报告的最大宽度将是:

  • 21 - (1,3*2) = 18,4cm
  • 29,7 - (1,3*2) = 27,1cm (landscape)
  • 21 - (1,3*2) = 18,4cm
  • 29,7 - (1,3*2) = 27,1cm(横向)