How do I change the papersize when priting
How do I change the papersize when priting
Hi Team from Stimulsoft, I like to set the papersize at runtime.
How do i do that?
I use this code (C#):
PrinterSettings MyPrinterSettings = new PrinterSettings();
MyPrinterSettings.Printername = "MyPrinter";
MyPrinterSettings.DefaultPageSettings.PaperSize = MyPrinterSettings.PaperSizes[1];
MyReport.Print(false, this.MyPrinterSettings);
MyReport is of type StiReport and both the printer and the paper size exist.
But somehow the size is not changed, it will always print on the standard size (the one set in the driver).
What do I do wrong?
Thanks a lot!
How do i do that?
I use this code (C#):
PrinterSettings MyPrinterSettings = new PrinterSettings();
MyPrinterSettings.Printername = "MyPrinter";
MyPrinterSettings.DefaultPageSettings.PaperSize = MyPrinterSettings.PaperSizes[1];
MyReport.Print(false, this.MyPrinterSettings);
MyReport is of type StiReport and both the printer and the paper size exist.
But somehow the size is not changed, it will always print on the standard size (the one set in the driver).
What do I do wrong?
Thanks a lot!
How do I change the papersize when priting
To change predefault papersize for the printer please change the following line in your code:
to
This static property sets the default paper size of the report page.
This occurs in the following method of the StiPrintProvider class:
As you can see you also may set a page width and a page height manually. Please notice then these properties of the StiPage object you have to set in the hundredth of inches units.
Thank you.
Code: Select all
MyPrinterSettings.DefaultPageSettings.PaperSize = MyPrinterSettings.PaperSizes[1];
Code: Select all
StiPrintProvider.PaperSizeForUsing = MyPrinterSettings.PaperSizes[1];
This occurs in the following method of the StiPrintProvider class:
Code: Select all
private object GetPaperSize(StiPage page, System.Drawing.Printing.QueryPageSettingsEventArgs e)
{
if (PaperSizeForUsing != null)return PaperSizeForUsing;
int pageWidth = (int)Math.Round(page.Unit.ConvertToHInches(page.PageWidth), 0);
int pageHeight = (int)Math.Round(page.Unit.ConvertToHInches(page.PageHeight), 0);
foreach (PaperSize ps in e.PageSettings.PrinterSettings.PaperSizes)
{
if ((ps.Width == pageWidth && ps.Height == pageHeight)||
(ps.Height == pageWidth && ps.Width == pageHeight))return ps;
}
return null;
}
Thank you.
How do I change the papersize when priting
Hi Edward,
thanks for the fast reply, I will test it at once.
Two more questions:
a) What happens if GetPaperSize return null. What Paper Size is then used?
b) How do I override the GetPaperSize event to set my own sizes? GetPaperSize is private ans therefore can't be overwritten.
Thanks a lot!!!
thanks for the fast reply, I will test it at once.
Two more questions:
a) What happens if GetPaperSize return null. What Paper Size is then used?
b) How do I override the GetPaperSize event to set my own sizes? GetPaperSize is private ans therefore can't be overwritten.
Thanks a lot!!!
How do I change the papersize when priting
In this case PaperSize is not used.a) What happens if GetPaperSize return null. What Paper Size is then used?
We have added static event StiPrintProvider.QueryPageSettings. It will be available in build from 21 Feb.b) How do I override the GetPaperSize event to set my own sizes? GetPaperSize is private ans therefore can't be overwritten.
Thank you.
How do I change the papersize when priting
It works! Thanks a lot!
How do I change the papersize when priting
Let us know if you need any help.
Thank you.
Thank you.