Developer Tools
|
Office Productivity Applications
|
Enterprise Solutions
|
|||||||||||||||||||||||







It is common to have the company logo in a report’s header/footer section. However, when such reports are exported to PDF, by default, a separate copy of the same image is stored for each page in the report, unnecessarily adding to the size of the PDF document. If you are using ReportBuilder for generating your reports, then you can use Gnostice eDocEngine to export the report to PDF and optimize the process to store only one copy of the image in the PDF file and reuse it on each page of the report as required.
eDocEngine provides features to refer to images being inserted into the document and later reuse them with the help of the reference. These features are exposed through OnEncodeGraphic and OnEncodeGraphicDone events of gtRBExportInterface component. Reusing common images can greatly reduce the file size of the PDF document. Our article will demonstrate how to do this, using an example report.
The following example uses a ReportBuilder report with three images in the page header and connects to ‘Biolife’ table of the ‘DBDEMOS’ database (which comes along with Delphi).
gtPDFEngine and gtRBExportInterface components to your project, for exporting the reports to PDFgtPDFEngine and gtRBExportInterface components on the main form of the project from the ‘eDocEngine’ and ‘eDocEngine Additional’ palettes respectively, in Delphi.Engine property of the gtRBExportInterface to gtPDFEngine.// Resource-Index of the current image being encoded FImgIndex: array of Integer; // Array-Index of the current image being encoded FImgNumber: Integer; // Total Number of Images used as resources FImgCnt: Integer;
// Initial settings
FImgCnt := 3;
SetLength(FImgIndex, FImgCnt);
for LI := Low(FImgIndex) to High(FImgIndex) do
FImgIndex[LI] := -1;
FImgNumber := 0;
OnEncodeGraphic event of gtRBExportInterface to write the below code.
procedure TForm1.gtRBExportInterface1EncodeGraphic( AObject: TObject; var UniqueImage: Boolean; var ReuseImageIndex: Integer); begin // Process images as resources UniqueImage := False; // Assign image resource index ReuseImageIndex := FImgIndex[FImgNumber]; end;
OnEncodeGraphicDone event of the gtRBExportInterface.
procedure TForm1.gtRBExportInterface1EncodeGraphicDone( AObject: TObject; ObjectImageIndex: Integer); begin // Store the image index for the first time only if (FImgIndex[FImgNumber] = -1) then FImgIndex[FImgNumber] := ObjectImageIndex; // Cyclicaly increment array index FImgNumber := (FImgNumber + 1) mod FImgCnt; end;
gtPDFEngine1.FileName := 'Sample'; gtRBExportInterface1.RenderDocument(ppReport1);
Downloads:
---o0O0o---
| Our Developer Tools | |
|---|---|
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
XtremePDFConverter VCLA Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents. |
|
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
XtremeDocumentStudio .NETMulti-format document-processing component suite for .NET developers |
PDFOne (for Java™)A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications. |
XtremeFontEngine (for Java)Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts |
| Our Office Productivity Applications |
|---|
Free PDF ReaderA free, fast, and portable application for viewing, printing and converting PDF documents. |
| Privacy | Legal | Feedback | Newsletter | Resellers | © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved. |
This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).