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

Dynamic Page 2

4 Answers 127 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
G W
Top achievements
Rank 1
G W asked on 01 Feb 2012, 05:00 AM
What i am trying to achieve on a report being exported as PDF, is to have a chart on the first page, then starting on page 2 have a table that shows the detail records that get summed up for the chart. 
Right now i have that working, but if the data is empty the PDF will still have 2 pages, one with an empty chart, one with an empty table.  To do that I have a single detail section that is around 9 inch height, with the table in the very bottom inch.

Is there a better way to cause a page break between two different elements?  And is there any way to have it not generate a page 2 if i set the visibility of the table to false when I detect that the datasource is empty?
Would it be better to put the chat inside a Report Header section and make sure that would take up the full first page?

4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 02 Feb 2012, 10:11 AM
Hi,

Explicit page breaks in a report can only be set via the PageBreak Property of the ReportSection Class i.e. page breaks can only be set per report section. You cannot apply page breaks after certain report item in a single section. Implicit page breaks occur when data does not fit on the physical page size you have defined and this is your current implementation.

Anyway, the detail section cannot shrink/take space that is no longer occupied automatically. To remove such space when you hide a report item, set its height to a very small value (e.g. 1mm). If you want a section/panel to shrink only at runtime you can set its Height property in the report constructor. Place the Height property assignment code just after the IntializeComponent() method call.

Kind regards,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
G W
Top achievements
Rank 1
answered on 02 Feb 2012, 07:26 PM
Is there any way to add extra DetailSections? So far it has seemed to me that only one of those is allowed.

I'm wondering if one way to do what i want is to put my chart in the ReportHeader, have a page break after that, then the grid in the DetailSection.  And in code just after the IntializeComponent() method call, I'll check if my datasource is empty and if it is I'll set the DetailSection.Visible = false.
Should that cause it to have an empty chart on the first page, and no second page?

Although now I need to have these different reports export into a single PDF, I'm thinking that will need to use SubReport objects, which might end up with an elegant way to fix this problem as well (maybe have the chart as one SubReport and the table as another SubReport).  Or is there a better way to do this? 


Thanks for your help, it does somewhat surprise me that Panels don't have the PageBreak property, but I can also see how that could make the layout code significantly more complicated, and if the panel isn't full-width might end up with confusing results.

Regards,
Greg
0
G W
Top achievements
Rank 1
answered on 02 Feb 2012, 11:06 PM
As for the part about generating multiple reports into a single PDF, I'm using a ReportBook that I'm building at run-time, and its working great.  I think SubReports would have been the wrong way to go for this usage.

I'm surprised how simple the code actually is so I'll share the method:
public static RenderingResult ExportReports(IEnumerable<Telerik.Reporting.Report> reports)
{
     Telerik.Reporting.ReportBook book = new Telerik.Reporting.ReportBook(reports);
 
     ReportProcessor reportProcessor = new ReportProcessor();
 
     //set any deviceInfo settings if necessary
     System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
 
     RenderingResult result = reportProcessor.RenderReport("PDF", report, deviceInfo);

     return result;
}
0
Steve
Telerik team
answered on 03 Feb 2012, 08:55 AM
Hi Greg,

My previous post contained explanation and solution for your case, namely when you hide an item, the section that contained it would not shrink automatically. To make that happen, set the height of the detail section to a very small value which would force it to shrink.
About detail section - yes, only one is available as only one is needed.

All the best,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
G W
Top achievements
Rank 1
Answers by
Steve
Telerik team
G W
Top achievements
Rank 1
Share this question
or