Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
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 .NET Developer Tools | |
---|---|
![]() Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
![]() PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
![]() Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
![]() 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. |
Our Java developer tools | |
---|---|
![]() Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
![]() PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
![]() StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2025 Gnostice Information Technologies Private Limited. All rights reserved. |