Page tree
Skip to end of metadata
Go to start of metadata

为了节省每次打印PDF文档时的工作量,可以在将报告导出为PDF格式时预设基本打印选项。

注意:打印预设属性仅在Professional Edition许可证中可用。 与Standard Edition License一起使用时,将显示评估消息。

在“页面/ RDL”和“部分”报告中,都可以使用“导出”对话框或通过代码设置“ PDF打印预设”属性。 PDF打印预设属性在以下查看器的“导出”对话框中可用。

  • Standalone Designer
  • End-User Designer
  • Web Viewer
  • WPF Viewer

使用“导出”对话框设置PDF打印预设


1、打开导出对话框。
2、在“导出”对话框的“导出格式”字段中,选择“便携式文档格式(PDF)”。

3、展开“打印预设”选项,并设置打印预设的必需属性。

注意:这些属性在1.7或更高版本的PDF中可用。 PDF版本1.6支持PageScaling属性。

4、单击“确定”关闭对话框。

通过代码设置PDF打印预设

1、从Visual Studio的“文件”菜单中,选择“新建”,然后选择“项目”。
2、在出现的“新建项目”对话框中,在VB.NET或C#语言下,单击“报告”节点。
3、选择要添加的报表应用程序的类型:

    • ActiveReports 14 Page Report Application
    • ActiveReports 14 RDL Report Application
    • ActiveReports 14 Section Report Application (xml-based)

4、在“名称”字段中,输入报表应用程序的名称,然后单击“确定”。 所选的报告类型将添加到您的项目中。
5、在设计视图中,双击表单标题栏以创建Form_Load事件。
6、添加以下代码以调用Export方法并在Form_Load事件中设置打印预设。

区域报表

Visual Basic.NET代码。 粘贴到Form_Load事件中


Dim sectionReport As New GrapeCity.ActiveReports.SectionReport()
Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\..\..\SectionReport1.rpx")
sectionReport.LoadLayout(xtr)
sectionReport.Run()

'Define settings for PDF
Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport()
p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17

'Set default print settings using PrintPresets class
p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None
p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge
p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two
p.PrintPresets.PaperSourceByPageSize = True
p.PrintPresets.PrintPageRange = "1-3"
p.Export(sectionReport.Document, Application.StartupPath + "\PrintPresets.pdf")

C#代码。 粘贴到Form_Load事件中


GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport();
System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + @"\..\..\SectionReport1.rpx");
sectionReport.LoadLayout(xtr);
sectionReport.Run();

//Define settings for PDF
GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17;

//Set default print settings using PrintPresets class
p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None;
p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge;
p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two;
p.PrintPresets.PaperSourceByPageSize = true;
p.PrintPresets.PrintPageRange = "1-3";
p.Export(sectionReport.Document, Application.StartupPath + "\\PrintPresets.pdf");

页面/RDL报表

Visual Basic.NET代码。 粘贴到Form_Load事件中


'Set the rendering extension and render the report.
Dim pdfExport = New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension()

'Define settings for PDF
Dim pdfSettings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()
pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17
pdfSettings.PrintOnOpen = True

'Set default print settings using PrintPresets class
Dim pdfPresetsSetting As New GrapeCity.ActiveReports.Export.Pdf.PrintPresets()
pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None
pdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge
pdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two
pdfPresetsSetting.PaperSourceByPageSize = True
pdfPresetsSetting.PrintPageRange = "1-3"

pdfSettings.PrintPresets = pdfPresetsSetting

Dim outputFile = New IO.FileInfo("..\..\PrintPresets.pdf")
Dim reportFile = New IO.FileInfo("..\..\PageReport1.rdlx")

Dim fileStreamProvider = New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputFile.Directory, Path.GetFileNameWithoutExtension(outputFile.FullName))

Using pageDocument = New GrapeCity.ActiveReports.PageReport(reportFile).Document
pageDocument.Render(pdfExport, fileStreamProvider, pdfSettings)
End Using

C#代码。 粘贴到Form_Load事件中


GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport();
System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + @"\..\..\SectionReport1.rpx");
sectionReport.LoadLayout(xtr);
sectionReport.Run();

//Define settings for PDF
GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
p.Version = GrapeCity.ActiveReports.Export.Pdf.Section.PdfVersion.Pdf17;

//Set default print settings using PrintPresets class
p.PrintPresets.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.None;
p.PrintPresets.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge;
p.PrintPresets.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.Two;
p.PrintPresets.PaperSourceByPageSize = true;
p.PrintPresets.PrintPageRange = "1-3";
p.Export(sectionReport.Document, Application.StartupPath + "\\PrintPresets.pdf");




相关资源:


注意

如需寻求在线帮助,请访问 ActiveReports 求助中心

如需了解更多ActiveReports产品特性,请访问 ActiveReports 官方网站

ActiveReports 官方技术交流群:109783140

下载产品体验产品功能:http://www.gcpowertools.com.cn/products/download.aspx?pid=16

  • No labels