如何在WebReport.Report创建中的ExportParameters事件教程

报表生成器FastReport .NET是适用于.NET Core 3,ASP.NET,MVC和Windows窗体的全功能报告库。使用FastReport .NET,您可以创建独立于应用程序的.NET报告。

近日,FastReport .Net升级到v2020.4版,在此版本中,添加了新的条形码:ITF-14和Deutsce Post Identcode,同时优化了多种性能(点击下方按钮下载),感兴趣的朋友可点击下方按钮下载最新版。

点击下载最新版FastReport .Net

Fastreport在线下单立享85折起!赶紧加入购物清单吧!

在FastReport 2020.1中,我们添加了更改导出参数的功能。因此,您必须在WebReport.Report中预订ExportParameters事件。

到目前为止,FastReport.Net库尚未提供对导出参数的访问。或更确切地说,它确实可以,但是仅对某些参数有效,并且借助于Web报表的各个属性。所有这些属性都是堆积在一起的,并且使用intelisense进行操作非常不方便,并且不能满足用户的所有需求。因此,决定使用特殊的ExportParameters事件为用户提供对导出对象的所有属性的访问权限。在事件处理程序中,您可以获取导出对象并设置所需的所有属性。因此,由于先前不可用的属性,现在可以更精确地配置导出。这是使用新事件的方法:

WebReport.Report.ExportParameters += (sender, e) =>
 {
 PDFExport export = e.Export as PDFExport;
 if (export != null)
 {
 export.Title = "test";
 export.DefaultPage = 2;
 }
 };

在此示例中,我们仅更改了页眉和默认页面。请注意,我们期望在处理时导出PDF,这意味着此代码将不适用于其他类型的导出。在一个处理程序中,您可以一次为几种导出类型指定设置。
æ‚¨å¯ä»¥ä¸€æ¬¡ä¸ºå‡ ç§å¯¼å‡ºç±»åž‹æŒ‡å®šè®¾ç½®

现在,让我们以PDF导出为例,说明可用的导出属性如何扩展。以前,WebReport为我们提供了一组导出属性,它们实际上是对PDFExport导出对象的属性的包装:

public string PdfTitle { get; set; }
 public string PdfAuthor { get; set; }
 public string PdfSubject { get; set; }
 public string PdfKeywords { get; set; }
 public string PdfCreator { get; set; }
 public string PdfProducer { get; set; }
 public string PdfUserPassword { get; set; }
 public bool PdfPrintScaling { get; set; }
 public string PdfOwnerPassword { get; set; }
 public bool PdfAllowModify { get; set; }
 public bool PdfAllowCopy { get; set; }
 public bool PdfAllowAnnotate { get; set; }
 public bool PdfA { get; set; }
 public bool PdfShowPrintDialog { get; set; }
 public bool PdfImagesOriginalResolution { get; set; }
 public bool PdfJpegCompression { get; set; }
 public bool PdfAllowPrint { get; set; }
 public bool PdfCenterWindow { get; set; }
 public bool PdfHideWindowUI { get; set; }
 public bool PdfFitWindow { get; set; }
 public bool PdfEmbeddingFonts { get; set; }
 public bool PdfBackground { get; set; }
 public bool PdfInteractiveForms { get; set; }
 public bool PdfPrintOptimized { get; set; }
 public bool PdfOutline { get; set; }
 public bool PdfDisplayDocTitle { get; set; }
 public bool PdfHideToolbar { get; set; }
 public bool PdfHideMenubar { get; set; }
 public bool PdfTextInCurves { get; set; }

我必须说,此属性列表包括主要和最受欢迎的属性,但不是全部。许多用户想要更多。现在,有了新的事件ExportParameters,它们就可以使用全套属性:

public bool HideWindowUI { get; set; } - hide user interface;
 public bool ShowPrintDialog { get; set; } – show printing dialog;
 public bool HideToolbar { get; set; } – hide toolbar in PDF viewer;
 public bool HideMenubar { get; set; } – hide menubar in PDF viewer;
 public GradientInterpolationPointsEnum GradientInterpolationPoints { get; set; } – gradient interpolation poinrs;
 public bool FitWindow { get; set; } – enable window fitting;
 public bool CenterWindow { get; set; } – center window;
 public bool PrintScaling { get; set; } – show scaling;
 public bool Outline { get; set; } – show contents;
 public MagnificationFactor DefaultZoom { get; set; }default zoom;
 public int RichTextQuality { get; set; } – RichText quality;
 public bool Compressed { get; set; } – compress file;
 public bool TransparentImages { get; set; } – transparent image;
 public bool DisplayDocTitle { get; set; } – display document title;
 public int DefaultPage { get; set; }default page number;
 public byte[] ColorProfile { get; set; } – color profile;
 public ExportType ExportMode { get; set; } – export type;
 public bool InteractiveForms { get; set; } – enable interactive forms;
 public bool IsDigitalSignEnable { get; set; } – enable digital signature;
 public bool SaveDigitalSignCertificatePassword { get; set; } – save digital signature certificate password;
 public X509Certificate2 DigitalSignCertificate { set; } – digital signature certificate;
 public string DigitalSignCertificatePath { get; set; } – digital signature certificate path;
 public string DigitalSignCertificatePassword { set; }; digital signature certificate password
 public string DigitalSignLocation { get; set; } – digital signature location;
 public string DigitalSignReason { get; set; } – digital signature reason;
 public string DigitalSignContactInfo { get; set; } – digital signature contact info;
 public CurvesInterpolationEnum CurvesInterpolation { get; set; } – curves interpolation;
 public bool AllowAnnotate { get; set; } – allow annotation;
 public bool AllowCopy { get; set; } – allow copying;
 public bool AllowModify { get; set; } – allow editing;
 public bool AllowPrint { get; set; } – allow print;
 public GradientQualityEnum GradientQuality { get; set; } – gradient quality;
 public PdfStandard PdfCompliance { get; set; } – PDF standard complience;
 public bool EmbeddingFonts { get; set; } – enable embedded fonts;
 public bool Background { get; set; } – enable background;
 public CurvesInterpolationEnum CurvesInterpolationText { get; set; } – interpolation text curves;
 public PdfColorSpace ColorSpace { get; set; } – color space;
 public bool ImagesOriginalResolution { get; set; } – use original image resolution;
 public bool PrintOptimized { get; set; } – print optimization;
 public bool JpegCompression { get; set; } – Jpeg image compression;
 public bool TextInCurves { get; set; } – make text in curves;
 public string Title { get; set; } – title;
 public string UserPassword { get; set; } – user password for encrypted documents;
 public int JpegQuality { get; set; } – Jpeg image quality;
 public string OwnerPassword { get; set; } – Owner’s password;
 public string Producer { get; set; } – Producer;
 public bool SvgAsPicture { get; set; } – Display Svg objects as pisctures;
 public string Keywords { get; set; } – Keywords;
 public string Subject { get; set; } – Subject of the document;
 public string Author { get; set; } – Author;
 public string Creator { get; set; } – Creator;

这没有考虑所有出口的共同属性。

让我们总结一下新的ExportParameters事件给我们带来的好处。通过将对象用于特定导出,我们只能访问该导出的属性。以前,需要从所有可能导出的属性的通用列表中进行选择,但这并不总是很方便,因为某些属性的名称并不明显,无法识别导出。您将使用Intellisense看到可用属性的完整列表,或者可以看到可用属性的完整列表。
FastReport Open Source与FastReport .Net间的功能差异还是非常明显的,如果您是企业用户或是需要更完整的功能,建议您直接购买FastReport .Net,盛夏狂欢,在线下单立享85折起!点击查看优惠价格,或咨询在线客服了解详情。
APS帮助提升企业生产效率,真正实现生产计划可视化呈现与控制,快速有效响应不同场景的生产计划,提高准时交货能力,提高产能和资源利用率
想要了解甘特图或慧都APS系统,请登录慧都网咨询在线客服,解决您的问题!
本文章转载自【慧都科技】evget欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,尊重他人劳动成果
原文链接:https://www.evget.com/article/2020/10/19/38680.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值