eDocEngine VCL
Create documents and reports in 18 formats
Compatibility
Delphi C++Builder

Reusing Your Existing Printing/Canvas Code With eDocEngine VCL

Render to documents what you render to screen or printer.
By Girish Patil

Every document-creation component in eDocEngine exposes a canvas property. You can write to this canvas just like you would write on a device canvas.

Your Existing Printing/Canvas Code

In your existing code, you may access the screen or printer canvas and render content on it. In the following code snippet, we access the canvas of a printer and render a report page on it.

Canvas1 := Printer.Canvas;
// Canvas1 := Bitmap1.Canvas;  // You may be writing to a bitmap … anything with a canvas

Report1.DrawPage(Canvas1);

...

procedure TReport.DrawPage(ACanvas: TCanvas);
begin
 with ACanvas do begin
  // Draw using TCanvas
  LTextRect := Rect(50, 100, 750, 200);
  TextRect(LTextRect, 75, 135, 'Gnostice eDocEngine Draw to Canvas Demo');
  FillRect(LTextRect);
  LTextRect :=  Rect(50, 250, 750, 350);

  // Draw using GDI
  Windows.FillRect(Handle, LTextRect, Brush.Handle);

  // Render text using GDI
  DrawText(Handle, PChar('Gnostice eDocEngine Draw to DC Demo'), -1,
           LTextRect, DT_CENTER+DT_VCENTER+DT_SINGLELINE);
 end;
end;

Printing/Canvas Code Reused With eDocEngine

When you upgrade your project with eDocEngine (to support generation of electronic documents), just replace the canvas object with the canvas of a document-creation engine component. In the following code example, we replace the bitmap canvas with the canvas of a PDF engine component. The rest of the code remains the same.

// Canvas1 := Printer.Canvas;

Canvas1 := gtPDFEngine1.Canvas;
Report1.DrawPage(Canvas1);

...

procedure TReport.DrawPage(ACanvas: TCanvas);
begin
 with ACanvas do begin
  // Draw using TCanvas
  LTextRect := Rect(50, 100, 750, 200);
  TextRect(LTextRect, 75, 135, 'Gnostice eDocEngine Draw to Canvas Demo');
  FillRect(LTextRect);
  LTextRect :=  Rect(50, 250, 750, 350);

  // Draw using GDI
  Windows.FillRect(Handle, LTextRect, Brush.Handle);

  // Render text using GDI
  DrawText(Handle, PChar('Gnostice eDocEngine Draw to DC Demo'), -1,
           LTextRect, DT_CENTER+DT_VCENTER+DT_SINGLELINE);
 end;
end;

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .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
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-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
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2017 Gnostice Information Technologies Private Limited. All rights reserved.