报告生成器FastReport .NET实践指南:如何创建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在线下单立享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,这意味着此代码将不适用于其他类型的导出。在一个处理程序中,您可以一次为几种导出类型指定设置。
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;
FastReport Open Source与FastReport .Net间的功能差异还是非常明显的,如果您是企业用户或是需要更完整的功能,建议您直接购买FastReport .Net,盛夏狂欢,在线下单立享85折起!点击查看优惠价格,或咨询在线客服了解详情。