Programatically Set Custom
Hi,
For one of our clients we are using crystal report developed using Visual Studio 2005. At the deployment phase we often come across the problem of Setting Custom PaperSize in report. Our client is using custom page size of 11in x 6in , whenever the report preview is shown the report viewer automatically sets the size to A4. So the user can't able to view or print the report. So i searched a lot to set paper size programatically. At last i found the following solution ,
i) First i have created Custom PageSize using ServerProperties (ie.,11in x 6in) and named it as 11x6.
ii) Then added the following method to my code,
public Int32 GetPaperSize(String sPrinterName, String sPaperSizeName)
{
PrintDocument docPrintDoc = new PrintDocument();
docPrintDoc.PrinterSettings.PrinterName = sPrinterName;
for (int i = 0; i < docPrintDoc .PrinterSettings.PaperSizes.Count; i++)
{
int raw = docPrintDoc.PrinterSettings.PaperSizes[i].RawKind;
if (docPrintDoc.PrinterSettings.PaperSizes[i].PaperName == sPaperSizeName)
{
return raw;
}
}
return 0;
}
iii) Then i called this method for the current Crystal Report Document, In my case
this.CrystalReport11.PrintOptions.PrinterName = "Wipro LQ 1050+DX
this.CrystalReport11.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)GetPapersizeID("Wipro LQ 1050+DX
PaperSize
in CrystalReportHi,
For one of our clients we are using crystal report developed using Visual Studio 2005. At the deployment phase we often come across the problem of Setting Custom PaperSize in report. Our client is using custom page size of 11in x 6in , whenever the report preview is shown the report viewer automatically sets the size to A4. So the user can't able to view or print the report. So i searched a lot to set paper size programatically. At last i found the following solution ,
i) First i have created Custom PageSize using ServerProperties (ie.,11in x 6in) and named it as 11x6.
ii) Then added the following method to my code,
public Int32 GetPaperSize(String sPrinterName, String sPaperSizeName)
{
PrintDocument docPrintDoc = new PrintDocument();
docPrintDoc.PrinterSettings.PrinterName = sPrinterName;
for (int i = 0; i < docPrintDoc .PrinterSettings.PaperSizes.Count; i++)
{
int raw = docPrintDoc.PrinterSettings.PaperSizes[i].RawKind;
if (docPrintDoc.PrinterSettings.PaperSizes[i].PaperName == sPaperSizeName)
{
return raw;
}
}
return 0;
}
iii) Then i called this method for the current Crystal Report Document, In my case
CrystalReport11 is the Report Document
this.CrystalReport11.PrintOptions.PrinterName = "Wipro LQ 1050+DX
";
this.CrystalReport11.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)GetPapersizeID("Wipro LQ 1050+DX
", "11x6";
Very nice to me. Thanks..........
ReplyDeleteCrystal Custom
It is very helpful.
ReplyDeleteCrystal Custom
Awesome looking blog. I love this.
ReplyDeleteCrystal Custom
This comment has been removed by a blog administrator.
ReplyDeleteIf the database you are using supports a query language such as SQL, you can write your own command which will be represented in Crystal Reports as a Table object
ReplyDeleteCrystal Custom
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteHi Bala,
ReplyDeleteThe Custom paper size(8X6)is affected in crystal preview but while
actually printing it will take letter size please give the solution
Hi sunny,
Deleteyou have to add the paper size in server property of that particular machine in which you have configured your printer.
Hi Bala,
DeleteI've done it already,But when i view the report in crystal report from Visual studio 2008 it shows properly but when i click on to print button & check preferences it shows the papersize as Letter & prints accordingly.