ActiveReports使用教程:如何使用PDF打印预设

本篇文章主要介绍了ActiveReports报表打印常用功能,以帮助您快速入门,下面我们将从以下几个方面进行介绍:PDF打印、在JS Viewer中打印,打印方法,高级打印选项。

ActiveReports是一款专注于.NET和.NET Core 平台的报表控件。通过拖拽式报表设计器,可以快速地设计Excel表格、Word文档、图表、数据过滤、数据钻取、精准套打等类型报表,全面满足 WinForm、ASP.NET、ASP.NET MVC、WPF 平台中各种报表的开发需要。同时,通过丰富的 API 可以灵活的实现报表创建、加载和运行时的个性化自定义需求。

ActiveReports最新试用版

本篇文章主要介绍了ActiveReports报表打印常用功能,以帮助您快速入门,下面我们将从以下几个方面进行介绍:PDF打印、在JS Viewer中打印,打印方法,高级打印选项。

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

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

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

  • Standalone Designer
  • End-User Designer
  • Web Viewer
  • WPF Viewer
  • 使用“导出”;对话框设置PDF打印预设

    1、打开导出对话框。

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

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

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

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

    通过代码设置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 PDFGrapeCity.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 classp.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 PDFDim pdfSettings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings()pdfSettings.Version = GrapeCity.ActiveReports.Export.Pdf.Page.PdfVersion.Pdf17pdfSettings.PrintOnOpen = True'Set default print settings using PrintPresets classDim pdfPresetsSetting As New GrapeCity.ActiveReports.Export.Pdf.PrintPresets()pdfPresetsSetting.PageScaling = GrapeCity.ActiveReports.Export.Pdf.Enums.PageScaling.NonepdfPresetsSetting.DuplexMode = GrapeCity.ActiveReports.Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdgepdfPresetsSetting.NumberOfCopies = GrapeCity.ActiveReports.Export.Pdf.Enums.NumberOfCopies.TwopdfPresetsSetting.PaperSourceByPageSize = TruepdfPresetsSetting.PrintPageRange = "1-3"pdfSettings.PrintPresets = pdfPresetsSettingDim 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).DocumentpageDocument.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 PDFGrapeCity.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 classp.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");

    本文转自葡萄城

    如果你对我们的产品感兴趣或者有任何疑问,欢迎咨询在线客服>>

    高端UI界面开发
    标签:

    来源:慧都

    声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

    上一篇 2020年6月12日
    下一篇 2020年6月12日

    相关推荐

    发表回复

    登录后才能评论