3 Answers, 1 is accepted
Thank you for writing.
This is possible and to achieve it you should create a custom class that implements IPrintable. For example:
class
MyPrinter : IPrintable
{
public
IPrintable Chart {
get
;
set
; }
public
IPrintable Pivot {
get
;
set
; }
private
int
pages;
public
int
BeginPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
{
this
.pages = Chart.BeginPrint(sender, args) + Pivot.BeginPrint(sender, args);
return
pages;
}
public
bool
EndPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
{
return
false
;
}
public
bool
PrintPage(
int
pageNumber, RadPrintDocument sender, System.Drawing.Printing.PrintPageEventArgs args)
{
if
(pageNumber < pages)
{
this
.Pivot.PrintPage(pageNumber, sender, args);
return
true
;
}
this
.Chart.PrintPage(1, sender, args);
return
false
;
}
public
Form GetSettingsDialog(RadPrintDocument document)
{
return
null
;
}
Then you can use the above class to create new PrintDocument:
RadPrintDocument doc =
new
RadPrintDocument();
doc.AssociatedObject =
new
MyPrinter()
{
Chart = chart1,
Pivot =
radPivotGrid1
};
RadPrintPreviewDialog dialog =
new
RadPrintPreviewDialog();
dialog.Document = doc;
dialog.ShowDialog();
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Telerik
Hello Dimitar,
thank you for your help. It was a fast and very helpful answer.
Some modifications had to be done in order to have a good solution.
1. Printersettings
2. First Chartprint then Pivotprint
3. Pagenumber check (in case of landscape = false different number of pages)
class MyPrinter : IPrintable
{
public IPrintable Chart { get; set; }
public IPrintable Pivot { get; set; }
private int pagesP;
private int pagesC;
private int pages;
public int BeginPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
{
this.pagesC = Chart.BeginPrint(sender, args);
this.pagesP = Pivot.BeginPrint(sender, args);
this.pages = pagesC + pagesP;
return pages;
}
public bool EndPrint(RadPrintDocument sender, System.Drawing.Printing.PrintEventArgs args)
{
return false;
}
public bool PrintPage(int pageNumber, RadPrintDocument sender, System.Drawing.Printing.PrintPageEventArgs args)
{
if (pageNumber <= pagesC)
{
this.Chart.PrintPage(pageNumber, sender, args);
return pageNumber < pages;
}
this.Pivot.PrintPage(pageNumber-pagesC, sender, args);
return pageNumber < pages;
}
public Form GetSettingsDialog(RadPrintDocument document)
{
return Pivot.GetSettingsDialog(document);
}
}
best regards
Thomas
Thank you for sharing your solution with the community. Do not hesitate to contact us if you have other questions.
Dimitar
Telerik