Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
In my project I have several reports that are all paper size A4, but I want to change that size for only one report. How can I change page size for that one report only?


Thank you!
Posted
Updated 6-Dec-10 5:06am
v3
Comments
Manfred Rudolf Bihy 5-Dec-10 8:57am    
Editied for spelling and grammar.

You can change the paper size at runtime based on your condition. The elements are derived from Printer settings.
C#
ReportDocument myReportDocument = new ReportDocument();
if(Session["PaperSize"].Equals("A4"))
{
myReportDocument.PrintOptions.PaperSize = PaperSize.PaperA4;
}
else if(Session["PaperSize"].Equals("A3"))
{
myReportDocument.PrintOptions.PaperSize = PaperSize.PaperA3;
}
DataSet MyDataSet = (DataSet)Session["MyDataSet"];
myReportDocument.SetDataSource(MyDataSet);
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();

Always come with your snippets which will help you to get solutions quickly for you.
 
Share this answer
 
Hi ,
I have problem of Custom paper size 8.5*6.00 in my crystal report. I have developed in VS 2008 and it working fine in my local but after i deploy in II7 server 2008 its taking default letter size, my code for custom size is as below,



System.Drawing.Printing.PrintDocument doctoprint = new System.Drawing.Printing.PrintDocument();
int rawKind = 0;
for (i = 0; i <= doctoprint.PrinterSettings.PaperSizes.Count - 1; i++)
{
if (doctoprint.PrinterSettings.PaperSizes[i].PaperName == "DC")
{
rawKind =
Convert.ToInt32(doctoprint.PrinterSettings.PaperSizes[i].GetType().GetField("kind", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes[i]));
// break;
// }
//}
rawKind = GetPaperSizeID();
rpt.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
CrystalReportViewer1.ReportSource = rpt;
 
Share this answer
 
The page size of the report is derived from the printer settings of the report. You can change this in the printer setup.

Have a look at these for clarity & suggestions:
Link 1[^]
Link 2[^]
Link 3[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900