如何删除从 SSRS 导出的 PDF 中的空白页
我有一份两页的 SSRS 报告。 当我将其导出为 PDF 时,由于其宽度,它需要 4 页,其中第 2 页和第 4 页显示了表中我的字段之一。 我尝试将报告属性中的布局尺寸设置为宽度=18英寸,高度=8.5英寸。
它在一页 PDF 中为我提供了整个表格,但第二页和第四页仍然是空白。
我这样做的方式不正确吗? 我还能如何摆脱这些空白页?
I have a two-page SSRS report. When I exported it to PDF it was taking 4 pages due to its width, where the 2nd and 4th pages were displaying one of my fields from the table. I tried to set the layout size in report properties as width=18in and height =8.5in.
It gave me the whole table in a single page of PDF, but I am still getting the 2nd and 4th pages blank.
Is the way I am doing it incorrect? How else can I get rid of those blank pages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(17)
在 BIDS 或 SSDT-BI 中,执行以下操作:
要在 PDF 中正确渲染正文宽度+ 左边距 + 右边距必须小于或等于页面宽度。 当您看到呈现空白页面时,几乎总是因为正文宽度加上边距大于页面宽度。
请记住:(正文宽度 + 左边距 + 右边距)<=(页面宽度)
In BIDS or SSDT-BI, do the following:
To render in PDF correctly Body Width + Left margin + Right margin must be less than or equal to Page width. When you see blank pages being rendered it is almost always because the body width plus margins is greater than the page width.
Remember: (Body Width + Left margin + Right margin) <= (Page width)
另一件要尝试的事情是将名为
ConsumeContainerWhitespace
的报告属性设置为True
(默认为false
)。 这对我来说就是这样解决的。Another thing to try is to set the report property called
ConsumeContainerWhitespace
toTrue
(the default isfalse
). That's how it got resolved for me.经过几个小时的努力解决这个问题后,我偶然发现了一个适合我的解决方案:
在 SSDT (2012) 中,我最初将页面设置/页面单位设置为厘米。 当我将其更改为“英寸”时,奇怪的是,我能够将报告导出为 PDF,而无需其他所有页面都为空白。
After hours of struggling with this problem, I stumbled upon a solution that worked for me:
In SSDT (2012), I had originally had my Page Setup/Page units set to Centimeters. When I changed this to Inches, strangely enough, I was able to export my report to PDF without having every other page be blank.
编辑 SSRS 文档时,最好先在设计界面上执行此操作(显示了 Visual Studio 2012,但可以在其他版本中完成),然后再计算任何数学。
下面的红色圆圈中的数字映射到以下步骤:
页面
; 因此会打印重影区域。此外,在某些情况下,人们可以通过设置
ConsumeContainerWhitespace 为
true
以自动占用空格。It is better to do this on the design surface (Visual Studio 2012 is shown but can be done in other versions) first before calculating any maths when editing an SSRS document.
Below the following numbers in red circles that map to these following steps:
page
which is larger than the actual controls; hence the ghost area being printed.Also in some circumstances one can just change a property of the report page by setting
ConsumeContainerWhitespace
totrue
to automatically consume the spaces.对我来说,问题是 SSRS 故意对待你的空白,就好像你希望它受到尊重一样:
除了空白之外,还要确保没有右边距。
The problem for me was that SSRS purposely treats your white space as if you intend it be honored:
As well as white space, make sure there is no right margin.
如果来自 SSRS 的页面为空白,您需要调整报告布局。 这比通过运行输出和后处理来修复布局问题的副作用要有效得多。
SSRS 在突破边缘界限方面非常挑剔。 只需调整报表上的文本框或其他控件,很容易意外地加宽/加长报表。 仔细检查报表表面的宽度和高度属性,并尽可能地挤压它们。 注意大的页眉和页脚。
If the pages are blank coming from SSRS, you need to tweak your report layout. This will be far more efficient than running the output through and post process to repair the side effects of a layout problem.
SSRS is very finicky when it comes to pushing the boundaries of the margins. It is easy to accidentally widen/lengthen the report just by adjusting text box or other control on the report. Check the width and height property of the report surface carefully and squeeze them as much as possible. Watch out for large headers and footers.
您是否尝试过查看报告右侧是否有空白? 如果是这样,您可以将其拖回报告末尾,然后将报告背景拖回同一位置。
Have you tried to see if there is any white space on the right of your report? If so you can drag it back to the end of your report and then drag the report background back to the same spot.
我使用 SSRS 已经超过 10 年了,上面的答案就是最佳答案。 但。 如果没有任何效果,并且您已经完全塞满了...从报告中删除项目,直到问题消失。 一旦确定了导致问题的行或报表项,请将其放入矩形容器中。 就是这样。 已经帮助我们很多很多次了! 额外的页面主要是由于报表项目超出了右边距而造成的。 当所有其他方法都失败时,将东西放在矩形内或项目右侧的空矩形内,可以阻止这种情况发生。 祝你好运!
I have worked with SSRS for over 10 years and the answers above are the go to answers. BUT. If nothing works, and you are completely stuffed....remove items from the report until the problem goes away. Once you have identified which row or report item is causing the problem, put it inside a rectangle container. That's it. Has helped us many many times! Extra pages are mostly caused by report items flowing over the right margin. When all else fails, putting things inside a rectangle or an empty rectangle to the right of an item, can stop this from happening. Good luck out there!
除了迄今为止最常见的边距问题之外,我还发现了两种额外的可能性:
+
连接文本。 您应该使用&
代替。In addition to the margins, the most common issue by far, I have also seen two additional possibilities:
+
to concatenate text. You should use&
instead.在报表 (myReport.rdlc) 的属性选项卡上,将“Keep Together”属性更改为 False。 我已经为这个问题苦苦挣扎了一段时间,这似乎解决了我的问题。

On the properties tab of the report (myReport.rdlc), change the "Keep Together" attribute to False. I've been struggling with this issue for a while and this seems to have solved my issue.

我最近继承了一份需要进行一些更改的报告。 遵循上述所有建议后,它没有帮助。 该报告历史上有这个额外的页面,但没有人能找出原因。
我右键单击 tablix 并选择属性。 选中了一个复选框,表示之后添加分页符。 删除后,它现在打印在一页上。
I recently inherited a report that I needed to make a few changes. After following all the recommendations above, it did not help. The report historically had this extra page, and nobody could figure out why.
I right clicked on the tablix and selected properties. There was a checkbox checked that said add a page break after. After removing this, it prints on one page now.
我通过执行以下操作解决了此问题。 (使用最新版本的报表生成器)
步骤 1.) 转到“查看”选项卡



步骤 2.) 选中属性复选框
步骤 3.) 单击报告正文内部(它将更新“属性”选项卡中的值)
步骤 4.) 此处不要考虑宽度
步骤 5.) 右键单击报告外部的灰色区域,然后单击报告属性
步骤 6.) 将左边距和右边距添加到正文宽度(如果等于 10,则将宽度设为 11)
步骤 7.) 保存
I fixed this issue by doing the following. ( Using the latest version of Report Builder )
Step 1.) Go to View Tab



Step 2.) Check the Properties checkbox
Step 3.) Click inside the body of your report (it will update values in properties tab)
Step 4.) Take not of the width here
Step 5.) Right click in the gray area outside the report and click report properties
Step 6.) Add your left + right margin to your body width ( if that equals 10 then make your width 11)
Step 7.) Save
如果您的报表包含子报表,并且允许子报表和层次结构增长,则子报表的宽度可能会超出正文的边界。
我在可以放置在单元格(跨越 2 列)中的子报表中遇到了类似的问题。 看起来跨度可以将其包含在设计器中,并且在 winform 或浏览器中渲染得很好,并且最初,它可以生成打印机输出(或 pdf 文件),而不会溢出到多余的页面上。
然后,在更改其他一些列宽度(并且不超过正文宽度加边距)后,winform 和浏览器渲染看起来仍然很好,但是当生成输出(打印机或 pdf)时,它会超出边距并写入右侧每页作为第二(第四等)页。 我可以通过增加放置子报表的 colspan 来消除我的问题。
无论您是否使用子报表,如果您有页面溢出并且您的正文设计适合页面的边缘,请寻找允许增长的东西以将正文的宽度推出。
If your report includes a subreport, the width of the subreport could push the boundaries of the body if subreport and hierarchy are allowed to grow.
I had a similar problem arise with a subreport that could be placed in a cell (spanning 2 columns). It looked like the span could contain it in the designer and it rendered fine in a winform or a browser and, originally, it could generate printer output (or pdf file) without spilling over onto excess pages.
Then, after changing some other column widths (and without exceeding the body width plus margins), the winform and browser renderings looked still looked fine but when the output (printer or pdf) was generated, it grew past the margins and wrote the right side of each page as a 2nd (4th, etc.) page. I could eliminate my problem by increasing colspan where the subreport was placed.
Whether or not you're using subreports, if you have page spillover and your body design fits within the margins of the page, look for something allowed to grow that pushes the width of the body out.
确保视觉工作室中的设计器不会超出您的最大宽度。 将鼠标悬停在右侧页面边框上并向左拖动以确保页面不会超出您所需的布局。
Make sure the designer in visual studio is not going beyond your max width. Hover over the right page border and drag to the left to make sure the page does not go over your desired layout.
我刚刚将所有元素宽度减小到小于 8 英寸,并且正在对其进行更正,
我是用鼠标做的
您的报告正文应短于 8 英寸。
I just reduced all elements Width shorter than 8 inch and it is being corrected,
I did that with mouse,
your report Body should be shorter than 8 inch.
我希望从上述所有解释中可以解决问题,但我想在这里添加我的观点。
您需要检查矩形、矩阵或表格等项目后面的所有空格,并尝试将其最小化。
第二种方法是,如果您仍然获得更多页面,请尝试减少报告中存在的项目之间的差距。 它以这种方式对我有用。
谢谢
I hope from above all explanations the issue might get resolved But I want to add my point of view here.
You need to check all the spaces after the items such as rectangle, matrix or table and try minimize it.
And the 2nd way is if still you're getting more pages then try to reduce the gap between the items present in your report. It works for me in this way.
Thanks
我已成功使用 pdftk 删除 pdf 中我不想要/不需要的页面。 您可以在此处下载该程序
您可以尝试如下操作。 摘自此处下的示例
从 in1.pdf 中删除“第 13 页”以创建 out1。 pdf
pdftk in.pdf cat 1-12 14端输出out1.pdf
或:
pdftk A=in1.pdf cat A1-12 A14端输出out1.pdf
I've successfully used pdftk to remove pages I didn't want/need in pdfs. You can download the program here
You might try something like the following. Taken from here under examples
Remove 'page 13' from in1.pdf to create out1.pdf
pdftk in.pdf cat 1-12 14-end output out1.pdf
or:
pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf