Reputation: 21
I need to set the page format of the report programatically with costum dimensions (Width and Height )like " 6*4 " or any other dimensions without creating format in the printer or in crystal report .
Upvotes: 0
Views: 2206
Reputation: 4318
To echo the comment @Arvo made, Crystal Reports has traditionally been heavily tethered to printers by design, probably dating back to the early 90's (I used my first version of Crystal with Visual Basic 3 for Windows 3.1). The way that I got around this limitation was to find a print driver that supported very large page height/width's, install it and tell the report to use that driver which would then allow for the report height/width to be changed to larger amounts (it doesn't matter if you actually have that printer, you just need the driver installed). Some virtual print drivers may work as well (think like, Print to PDF).
It's not ideal by any means but I have done it myself and it will do the trick.
This is some old code I had saved that I don't know the origin off, you can see if it works to programmatically allow changing of the size (it might have be used in tandem with the print driver).
var cr = new ReportDocument();
var printerSettings = new System.Drawing.Printing.PrinterSettings();
var pageSettings = new System.Drawing.Printing.PageSettings(printerSettings);
pageSettings.PaperSize = new System.Drawing.Printing.PaperSize("newsize", 3000, 3000); // Custom size (100=1 inch)
pageSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
cr.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;
cr.PrintOptions.CopyFrom(printerSettings, pageSettings);
Upvotes: 2