I have created next custom panel.
public
class
PrintablePanel : RadPanel, IPrintable
{
public
PrintablePanel()
{
}
public
int
BeginPrint(RadPrintDocument sender, PrintEventArgs args)
{
return
1;
}
public
bool
EndPrint(RadPrintDocument sender, PrintEventArgs args)
{
return
true
;
}
public
Form GetSettingsDialog(RadPrintDocument document)
{
return
new
PrintSettingsDialog(document);
}
public
bool
PrintPage(
int
pageNumber, RadPrintDocument sender, PrintPageEventArgs args)
{
Bitmap bmp =
new
Bitmap(
this
.Width,
this
.Height);
bool
printLandscape = Width > Height;
Size printSize =
this
.Size;
if
(Size.Width > Convert.ToInt32(args.PageSettings.PrintableArea.Width) ||
Size.Height > Convert.ToInt32(args.PageSettings.PrintableArea.Height))
{
printSize =
new
Size(Convert.ToInt32(args.PageSettings.PrintableArea.Width), Convert.ToInt32(args.PageSettings.PrintableArea.Height));
bmp = Imageworker.ResizeImage(bmp, printSize.Width, printSize.Height);
}
args.PageSettings.Landscape = printLandscape;
this
.DrawToBitmap(bmp,
new
Rectangle(
new
Point(0, 0), printSize));
args.Graphics.DrawImage(bmp, Point.Empty);
sender.
return
false
;
}
public
void
Print()
{
RadPrintDocument doc =
this
.CreatePrintDocument();
doc.Print();
}
public
void
PrintPreview()
{
RadPrintDocument doc =
this
.CreatePrintDocument();
RadPrintPreviewDialog dialog =
new
RadPrintPreviewDialog(doc);
dialog.ThemeName =
this
.ThemeName;
dialog.ShowDialog();
}
private
RadPrintDocument CreatePrintDocument()
{
RadPrintDocument doc =
new
RadPrintDocument();
doc.AssociatedObject =
this
;
return
doc;
}
}
The problem I have is that when I want to print a panel that's larger then the papersize, it won't resize.
Setting the page to landscape also doesn't work.
See my code in the following method:
public bool PrintPage(int pageNumber, RadPrintDocument sender, PrintPageEventArgs args)