1

We have a SSRS report that shows the Head, Body and Footer properly in the MS report viewer. But once we export the report to PDF then the report shows a gap between the header and the body components. Here is the Report Viewer preview : Microsoft Report Viewer

And once we exported the same report to PDF file : enter image description here

The tablix is actually a sub report , So we checked the report properties and removed all the margins for it. Here is the report properties : enter image description here

I found some what similar questions , but it wasn't helpful.

Question 1

Question 2

So the question is how can we avoid the whitespace at the top between the header and body while exporting to PDF ?

Example 2: If I remove the small space in the header below all the controls then it shows like this in the preview : MS report viewer preview

and once we export to PDF then we can see that the tablix went over the header. PDF Sceenshot

So in this example we don't have a extra space in the header, So the MS Report Viewer preview is okay , but when we try to export then the tablix will go over the header. To overcome this issue I added a small extra space in the header

Header: enter image description here

Makesh
  • 335
  • 4
  • 15
  • How is the subreport positioned in the report body? Is it flush against the top of the section? Does its location have a Y coordinate of 0? – Ann L. Jan 08 '23 at 20:25
  • I'm not talking about the report that is assigned to the subreport control, but the actual subreport control itself, within the main report. – Ann L. Jan 08 '23 at 20:26
  • If the header and the subreport are both components in the same section of the report, I wonder whether the header is requiring less vertical space in the PDF than it does in the preview, and therefore is "shorter", creating that gap. – Ann L. Jan 08 '23 at 20:30
  • @AnnL. Yes, it does location => 0in,0in – Makesh Jan 09 '23 at 11:46
  • I'm curious as to whether the gap is part of the header or the main body. Try changing the background color of the header (behind all the text or controls) and see whether the gap is the header background color, or the main body background color. – Ann L. Jan 09 '23 at 16:09
  • @AnnL. Yes, you're right ! , it's actually from the header, NOT from the body. I changed the background color. But why doesn't show in the preview and only in exporting to PDF ? – Makesh Jan 10 '23 at 05:32
  • Does the header have a container control on it (like a rectangle or a tablix), or are the text boxes placed directly on it? – Ann L. Jan 10 '23 at 13:54
  • My guess for "why" is that -- somehow -- the amount of space the text boxes take up is a function of the size of the font, and that the font size is smaller, relative to the absolute size of the page, in the PDF as opposed to the preview. – Ann L. Jan 10 '23 at 13:56
  • So -- if my guess is right -- the size _allowed_ for the header stays fixed, but the size _needed_ for the header shrinks in the PDF, because -- if my guess is right -- the font, at a given point size, is smaller in the PDF than it is in the preview. – Ann L. Jan 10 '23 at 13:57
  • And I don't know why that would be, but it would explain what we see! – Ann L. Jan 10 '23 at 13:58
  • If you have a tablix or a rectangle or some other control as background in the header, I would guess that its size is also a function of font point size (esp since "expand as needed" (might have the name wrong) is set to True by default). And that the same phenomenon happens with that. – Ann L. Jan 10 '23 at 14:00
  • It doesn't have any container controls in the header, It's purely textboxes. I added some space in the header below after all the controls to over come one issue in PDF. If I remove that space in the header below then the grid will go over the header in the PDF. I will attach that screenshot as Example 2. – Makesh Jan 14 '23 at 05:07
  • Are Examples 1 and 2 part of the same report, or different reports? Because, with full respect, I had the impression we had solved the problem for Example 1. (If the problem is defined as "How do I get the exported PDF to look the way I want?") – Ann L. Jan 14 '23 at 23:40
  • If the question is more like "_Why_ do the preview and the exported PDF not match exactly?" I don't have an answer. My best guess is above, having to do with subtleties in font sizes. – Ann L. Jan 14 '23 at 23:42
  • If Example 2 is of a different report that has a different problem, that should probably be a different question. – Ann L. Jan 14 '23 at 23:42
  • @AnnL. I think you got confused because I posted the example 2. Yes , these are different reports, but I just want to show you how the report preview/behavior once we export to pdf. As you mentioned your best guess like font size , nothing to do with the gap between the header and body. The textboxes has enough space to accommodate the parameter values in it. There is no chance for grow up / and second line. Currently the font size is 8pt. So I think we can't say it is a solution for this problem. – Makesh Jan 16 '23 at 10:57

0 Answers0