I created a Crystal report (.rpt file) in Crystal Designer. I configured Page Setup. I want to retrieve e.g. page orientation, page width, page high programmatically in C#. How to do it? Note that I want to retrieve page settings, no print settings. I don't want to edit page settings, I only need to read it.
===EDIT===
Following figure shows my page setup:
PrintOptions.PageContentWidth
and PrintOptions.PageContentHeight
in C# have different values.
ReportDocument rp = new ReportDocument();
rp.Load(path_to_my_report_file);
Console.WriteLine(rp.PrintOptions.PageContentHeight);
Console.WriteLine(rp.PrintOptions.PageContentWidth);
Output:
5670
8505
I need to retrieve page width and height to set they in PaperSize (myPaperSize = new System.Drawing.Printing.PaperSize(name, width, height);
)
ReportDocument.PrintOptions
should give you the numbers that you need. For example, for the page width, using members ofPrintOptions
:However, these values are in TWIPS, where 1440 twips = 1 inch. (I have no idea what the proper capitalization is...)
On the other hand,
System.Drawing.Printing.PaperSize
uses numbers in hundredths of an inch, so you would have to convert: