/// <summary> /// Writes the trailer information on a PDF file. Always call this method after calling <see cref="BeginExport"/> /// </summary> public void EndExport() { PdfCanvas.EndDoc(); FRenderer.DisposeFontCache(); FPdfStream = null; PdfCanvas = null; }
/// <summary> /// Exports the associated xls workbook to a graphics stream. You need to provide a /// Graphics object with the correct dimensions. (To get the needed dimensions, use <see cref="GetRealPageSize()"/> /// </summary> /// <param name="imgData">Graphics where the image will be stored. Set it to null to skip the page.</param> /// <param name="exportInfo"> Information needed to export, cached for speed. The first time you call this method (or when you change xls.ActiveSheet), make exportInfo=null</param> public bool ExportNext(Graphics imgData, ref TImgExportInfo exportInfo) { FRenderer.CreateFontCache(); try { Bitmap bmp = null; try { if (imgData == null) { bmp = BitmapConstructor.CreateBitmap(1, 1); imgData = Graphics.FromImage(bmp); imgData.PageUnit = GraphicsUnit.Point; } IFlxGraphics aCanvas = new GdiPlusGraphics(imgData); GraphicsUnit OriginalUnits = imgData.PageUnit; try { imgData.PageUnit = GraphicsUnit.Point; FRenderer.SetCanvas(aCanvas); try { if (exportInfo == null) { exportInfo = GetExportInfo(aCanvas); } exportInfo.IncCurrentPage(); if (exportInfo.CurrentPage > exportInfo.TotalPages) { return(false); } int SaveActiveSheet = Workbook.ActiveSheet; try { Workbook.ActiveSheet = exportInfo.CurrentSheet; int CurrentLogicalPage = -1; if (ResetPageNumberOnEachSheet) { CurrentLogicalPage = exportInfo.ActiveSheet.FCurrentPage; } else { CurrentLogicalPage = exportInfo.CurrentPage; } TOneImgExportInfo OneResult = exportInfo.ActiveSheet; if (LastInitSheet != exportInfo.CurrentSheet) { TXlsCellRange ra; int p; RectangleF[] r; FRenderer.InitializePrint(aCanvas, OneResult.PageBounds, OneResult.PageBounds, OneResult.PrintRanges, out r, out p, out ra); LastInitSheet = exportInfo.CurrentSheet; } if (bmp == null) { OnBeforePaint(new ImgPaintEventArgs(imgData, CalcPageBounds(exportInfo.ActiveSheet.PageBounds), exportInfo.CurrentPage, exportInfo.ActiveSheet.CurrentPage, exportInfo.TotalPages)); } FRenderer.GenericPrint(aCanvas, OneResult.PageBounds, OneResult.PrintRanges, CurrentLogicalPage, OneResult.PaintClipRect, exportInfo.TotalLogicalPages(ResetPageNumberOnEachSheet), bmp == null, OneResult.PagePrintRange, ref OneResult.FCurrentPrintArea); aCanvas.ResetClip(); if (bmp == null) { OnAfterPaint(new ImgPaintEventArgs(imgData, CalcPageBounds(exportInfo.ActiveSheet.PageBounds), exportInfo.CurrentPage, exportInfo.ActiveSheet.CurrentPage, exportInfo.TotalPages)); } } finally { Workbook.ActiveSheet = SaveActiveSheet; } } finally { FRenderer.SetCanvas(null); } } finally { imgData.PageUnit = OriginalUnits; } } finally { if (bmp != null) { bmp.Dispose(); imgData.Dispose(); } } } finally { FRenderer.DisposeFontCache(); } return(true); }
/// <summary> /// Raises the EndPrint event. It is called after the Print method has finished. /// </summary> /// <param name="e">A <see cref="PrintEventArgs"/> that contains the event data.</param> /// <remarks> /// This method is overridden to print an Excel document. /// </remarks> protected override void OnEndPrint(PrintEventArgs e) { FRenderer.DisposeFontCache(); Workbook.ActiveSheet = SaveActiveSheet; base.OnEndPrint(e); }