This is a migrated thread and some comments may be shown as answers.

Subreports overlap when exported to pdf

8 Answers 598 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan Emptage
Top achievements
Rank 1
Ryan Emptage asked on 16 Feb 2009, 10:08 AM
I am creating the subreports programmatically with the Dock property set to "Top".
The subreports render fine in the web viewer but when exported to pdf they overlap.
I have about 6 subreport in total, however only two of them are overlapping.

Any ideas?

8 Answers, 1 is accepted

Sort by
0
Ryan Emptage
Top achievements
Rank 1
answered on 16 Feb 2009, 10:30 AM
The overlapping also occurs when exporting to TIF and RTF, but not to Excel.
0
Accepted
Steve
Telerik team
answered on 16 Feb 2009, 12:39 PM
Hi Ryan,

From the information you have provided it is impossible for us to give you any helpful feedback as we cannot be sure what is causing the undesired behavior, but doing things programmatically might be it. Please, elaborate more in-depth about what you are trying to accomplish with the docked subreports, so we can better assist you.
Now up to our guesses/suggestions: generally when docking report items within a report section (in your case the items are sub-reports), you should always specify a nonzero size for each docked item, otherwise it is not possible for the report engine to determine the correct relationship between them, when generating the report layout on rendering.

Let me explain this with a small example. Suppose that we have two report items: item1 and item2. If we have not specified the location and size of any of them, it is valid to assume that they are all set to zero by default:

item1.Left == 0; item1.Top == 0; item1.Width == 0; item1.Height == 0;
item2.Left == 0; item2.Top == 0; item2.Width == 0; item2.Height == 0.

Now we are docking both items to the top of the detail section, so their locations and sizes are adjusted according to the dimensions of the detail section:

item1.Left == 0; item1.Top == 0; item1.Width == detail.Width; item1.Height == 0;
item2.Left == 0; item2.Top == 0; item2.Width == detail.Width; item2.Height == 0.

Here detail.Width is the width of the detail section. You can see for yourself that item1 and item2 are in fact overlapping in the report, and that would explain why the docking is not working properly.

Now, lets specify a nonzero height for each item, before docking them in the detail section:

item1.Left == 0; item1.Top == 0; item1.Width == detail.Width; item1.Height == 1pt;
item2.Left == 0; item2.Top == 1pt; item2.Width == detail.Width; item2.Height == 1pt.

It is obvious now, that item1 and item2 are not overlapping, and the docking should work as expected.

Please check if this is the case, and if not provide us with more details and preferably a sample report showing the erroneous behavior.

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ryan Emptage
Top achievements
Rank 1
answered on 16 Feb 2009, 02:44 PM
Hi Steve

Thanks for the reply.

The requirement is that the end user can choose which subreports they want to print.
E.g.Out of 6 subreports, a user may only want to print subreports 1,3 and 5.

Instead of dragging the subreports from the toolbox and thus setting the Y position, I chose to programmatically create the subreports and dock them to the Top, so that I wouldn't have to change the Y position of subreports programmatically depending on whether the user had chosen to print it or not.
I just felt that using the Dock property would save me a bit of coding time.

Having read your reply, I have now set the height of all subreports to 1cm - which I was not doing before, so thank you for that
Example

//Personal Details 
            if (Convert.ToBoolean(_dtReportSections.Rows[0]["print"]) == true
            { 
                SubReport srPersonal = new SubReport(); 
                srPersonal.Name = "srPersonal"
                srPersonal.Height = new Unit(1, UnitType.Cm); 
                srPersonal.Dock = DockStyle.Top; 
                srPersonal.NeedDataSource += new EventHandler(srPersonal_NeedDataSource); 
                PersonalDetails PersonalDetailsReport = new PersonalDetails(); 
                srPersonal.ReportSource = PersonalDetailsReport; 
                this.detail.Items.Add(srPersonal); 
            } 

This has fixed the problem with pdf export...however the something odd has now happened when the report is rendered in the web viewer. My report has now split into three pages. Page 1 detail is blank, page 2 prints all the detail, page 3 is blank.

Do you think it would be better if I didn't use the Dock property at all and handled the Y position of the subreports programmatically instead?
0
Ryan Emptage
Top achievements
Rank 1
answered on 16 Feb 2009, 04:04 PM
Some screenshots to illustrate what is happening.

Report Page 1

Report Page 2

Report Page 3









0
Steve
Telerik team
answered on 16 Feb 2009, 04:30 PM
Hi Ryan,

Please select your Group and set the GroupKeepTogether property to All.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ryan Emptage
Top achievements
Rank 1
answered on 16 Feb 2009, 04:42 PM
Thanks Steve, but that did not fix it.
Report is still spread over three pages.
0
Steve
Telerik team
answered on 16 Feb 2009, 05:29 PM
Hello Ryan,

Can you please verify that you have set the GroupKeepTogether property to All (as shown on the screenshot) and not KeepTogether of a Group Header/Footer? If this is the case and the problem still persists, please open a support ticket and attach a sample report, where the issue can be observed.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ryan Emptage
Top achievements
Rank 1
answered on 17 Feb 2009, 10:59 AM
The Pagebreak property of the detail section was set to true (I don't remember doing that) so I have changed it to false and everything is working great now. Thanks for your help.
Tags
General Discussions
Asked by
Ryan Emptage
Top achievements
Rank 1
Answers by
Ryan Emptage
Top achievements
Rank 1
Steve
Telerik team
Share this question
or