Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

i want to create a Crystal report in .net C# with custom page size by code,

i use the following code for it but its work only on local machine. not in other machine


C#
System.Drawing.Printing.PrintDocument doctoprint = new System.Drawing.Printing.PrintDocument();
objPkPln.PrintOptions.PrinterName = strPrinterName.Trim();

int rawKind = 0;

                        for (int i = 0; i < doctoprint.PrinterSettings.PaperSizes.Count - 1; i++)
                        {
                            //int rawKind;
                            if (doctoprint.PrinterSettings.PaperSizes[i].PaperName == "WMS_PS")
                            {
                                rawKind = Convert.ToInt32(doctoprint.PrinterSettings.PaperSizes[i].GetType().GetField("kind", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(doctoprint.PrinterSettings.PaperSizes[i]));
                                objPkPln.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
                                MessageBox.Show("WMS_PS Selected");
                            }
                        }

                        crstlrptViewer.ReportSource = objPkPln;
                        crstlrptViewer.DisplayGroupTree = false;


i use the papername = "WMS_PS" the WMS_PS is a printing form that i created in Printers setting,
although is set that form in other PC, its not work there....
so any one have an idea for solve it.....


Thanks
Posted
Updated 6-May-13 3:07am
v2

1 solution

You should set papername custom and then set paper's Height & width

Happy Coding!
:)
 
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