如何在C#中以编程方式检索Crystal页面设置? [英] How to retrieve Crystal page setting programmatically in C#?
问题描述
我在Crystal Designer中创建了一个Crystal报表(.rpt文件)。我配置了页面设置。我想要检索页面方向,页面宽度,页面高编程方式在C#。怎么做?注意,我想检索页面设置,没有打印设置。我不想编辑页面设置,我只需要阅读它。
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
和 C#中的PrintOptions.PageContentHeight
有不同的值。
ReportDocument rp = new ReportDocument();
rp.Load(path_to_my_report_file);
Console.WriteLine(rp.PrintOptions.PageContentHeight);
Console.WriteLine(rp.PrintOptions.PageContentWidth);
输出:
5670
8505
我需要检索页面宽度和高度他们在PaperSize( myPaperSize = new System.Drawing.Printing.PaperSize(name,width,height);
)
I need to retrieve page width and height to set they in PaperSize (myPaperSize = new System.Drawing.Printing.PaperSize(name, width, height);
)
推荐答案
ReportDocument.PrintOptions
应该给你所需要的数字。例如,对于页面宽度,使用 PrintOptions
的成员:
ReportDocument.PrintOptions
should give you the numbers that you need. For example, for the page width, using members of PrintOptions
:
PageContentWidth + PageMargins.leftMargin + PageMargins.rightMargin
在 TWIPS (其中 1440 twips = 1英寸)中。 (我不知道适当的大写是什么...)
However, these values are in TWIPS, where 1440 twips = 1 inch. (I have no idea what the proper capitalization is...)
另一方面, System.Drawing.Printing.PaperSize
使用百分之一英寸的数字,因此您必须转换:
On the other hand, System.Drawing.Printing.PaperSize
uses numbers in hundredths of an inch, so you would have to convert:
[Dimension in hundredths of an inch] = [Dimension in TWIPS] / 1440.0 * 100
这篇关于如何在C#中以编程方式检索Crystal页面设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!