如何删除从 SSRS 导出的 PDF 中的空白页

发布于 2024-07-10 18:52:07 字数 200 浏览 20 评论 0原文

我有一份两页的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

能否归途做我良人 2024-07-17 18:52:07

在 BIDS 或 SSDT-BI 中,执行以下操作:

  1. 单击报告 > 报告属性> 布局选项卡(SSDT-BI 中的页面设置选项卡)
  2. 记下页面宽度左边距右边距的值
  3. 关闭并继续返回设计界面
  4. 在“属性”窗口中,选择正文
  5. 单击 + 符号展开“大小”节点
  6. 记下宽度的值

要在 PDF 中正确渲染正文宽度+ 左边距 + 右边距必须小于或等于页面宽度。 当您看到呈现空白页面时,几乎总是因为正文宽度加上边距大于页面宽度。

请记住:(正文宽度 + 左边距 + 右边距)<=(页面宽度)

In BIDS or SSDT-BI, do the following:

  1. Click on Report > Report Properties > Layout tab (Page Setup tab in SSDT-BI)
  2. Make a note of the values for Page width, Left margin, Right margin
  3. Close and go back to the design surface
  4. In the Properties window, select Body
  5. Click the + symbol to expand the Size node
  6. Make a note of the value for Width

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)

栖竹 2024-07-17 18:52:07

另一件要尝试的事情是将名为 ConsumeContainerWhitespace报告属性设置为 True(默认为 false)。 这对我来说就是这样解决的。

Another thing to try is to set the report property called ConsumeContainerWhitespace to True (the default is false). That's how it got resolved for me.

裂开嘴轻声笑有多痛 2024-07-17 18:52:07

经过几个小时的努力解决这个问题后,我偶然发现了一个适合我的解决方案:

在 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.

enter image description here

獨角戲 2024-07-17 18:52:07

编辑 SSRS 文档时,最好先在设计界面上执行此操作(显示了 Visual Studio 2012,但可以在其他版本中完成),然后再计算任何数学。

下面的红色圆圈中的数字映射到以下步骤:

  1. 在设计界面中,有时编辑器会创建一个比实际控件大的页面; 因此会打印重影区域。
  2. 调整控件大小。 直观地查看宽度/高度,看看是否无法将页面中带到设计图面上将其调整为控件实际需要的空间,仅此而已。
  3. 然后尝试创建 PDF 并查看是否可以解决该问题。
  4. 如果#3 未能解决问题,则说明某些控件需要过多的实际页面大小,并且在长度/宽度上超出。 因此,需要缩小控件的大小以适应较小的页面大小。

手动修复的步骤


此外,在某些情况下,人们可以通过设置 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:

  1. In the design surface, sometimes the editor will create a page which is larger than the actual controls; hence the ghost area being printed.
  2. Resize to the controls. Visually look at the width/height and see if you can't bring in the page on the design surface to size it to the space actually needed by the controls and no more.
  3. Then try to create a PDF and see if that fixes it.
  4. If #3 does not resolve the issue, then there are controls requiring too much of the actual page size and going over in either length/width. So one will need to make the size of the controls smaller to accommodate a smaller page size.

Steps to manually remediate


Also in some circumstances one can just change a property of the report page by setting ConsumeContainerWhitespace to true to automatically consume the spaces.

笨笨の傻瓜 2024-07-17 18:52:07

对我来说,问题是 SSRS 故意对待你的空白,就好像你希望它受到尊重一样:

在此处输入图像描述

除了空白之外,还要确保没有右边距。

The problem for me was that SSRS purposely treats your white space as if you intend it be honored:

enter image description here

As well as white space, make sure there is no right margin.

浅唱ヾ落雨殇 2024-07-17 18:52:07

如果来自 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.

_畞蕅 2024-07-17 18:52:07

您是否尝试过查看报告右侧是否有空白? 如果是这样,您可以将其拖回报告末尾,然后将报告背景拖回同一位置。

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.

挽容 2024-07-17 18:52:07

我使用 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!

郁金香雨 2024-07-17 18:52:07

除了迄今为止最常见的边距问题之外,我还发现了两种额外的可能性:

  1. 使​​用 + 连接文本。 您应该使用 & 代替。
  2. 文本超出指定文本框的宽度。 因此,如果您的文本框只能容纳 30 个字符,而您尝试在其中塞入 300 个字符,那么您可能会得到额外的页面。

In addition to the margins, the most common issue by far, I have also seen two additional possibilities:

  1. Using + to concatenate text. You should use & instead.
  2. Text overflowing the width of the specified textbox. So if your textbox only holds 30 characters and you try to cram 300 in there, you might end up with extra pages.
森末i 2024-07-17 18:52:07

在报表 (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.
enter image description here

烂柯人 2024-07-17 18:52:07

我最近继承了一份需要进行一些更改的报告。 遵循上述所有建议后,它没有帮助。 该报告历史上有这个额外的页面,但没有人能找出原因。

我右键单击 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.

enter image description here

神经暖 2024-07-17 18:52:07

我通过执行以下操作解决了此问题。 (使用最新版本的报表生成器)

步骤 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 enter image description here
Step 3.) Click inside the body of your report (it will update values in properties tab) enter image description here
Step 4.) Take not of the width here
Step 5.) Right click in the gray area outside the report and click report properties enter image description here
Step 6.) Add your left + right margin to your body width ( if that equals 10 then make your width 11) enter image description here
Step 7.) Save

执笔绘流年 2024-07-17 18:52:07

如果您的报表包含子报表,并且允许子报表和层次结构增长,则子报表的宽度可能会超出正文的边界。
我在可以放置在单元格(跨越 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.

一腔孤↑勇 2024-07-17 18:52:07

确保视觉工作室中的设计器不会超出您的最大宽度。 将鼠标悬停在右侧页面边框上并向左拖动以确保页面不会超出您所需的布局。

输入图片此处描述

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.

enter image description here

长不大的小祸害 2024-07-17 18:52:07

我刚刚将所有元素宽度减小到小于 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.

悸初 2024-07-17 18:52:07

我希望从上述所有解释中可以解决问题,但我想在这里添加我的观点。

您需要检查矩形、矩阵或表格等项目后面的所有空格,并尝试将其最小化。
第二种方法是,如果您仍然获得更多页面,请尝试减少报告中存在的项目之间的差距。 它以这种方式对我有用。

谢谢

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

夏至、离别 2024-07-17 18:52:07

我已成功使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文