[Lazarus] PDF generator, try 2

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Fri Apr 1 02:16:18 CEST 2016


On 2016-03-31 22:18, Jesus Reyes A. wrote:
> TPDFPage has some basic primitives for drawing: lines, rects, ellipses and  
> images. I don't see a way to add our own (except by patches to fpPDF of  
> course)


I like the idea of giving developers the ability to extend TPDFPage with
more drawing functions. Good news is, it is quite possible already, with
one minor modifications - TPDFPages needs to surface a Add(APage:
TPDFPage) procedure.

I just made the change locally and managed to add my own drawing
function as follows:

type
  // page class with new custom drawing methods
  TMyPDFPage = class(TPDFPage)
  public
    procedure DrawRoundedRect(...);
  end;


  // Add your custom page as follows
  P := TMyPDFPage.Create(Doc);
  Doc.Pages.Add(P); // global Page Object list
  lSection.AddPage(P); // which Section our page belongs too


  // painting our custom page.  P is a TMyPDFPage type.
  P := TMyPDFPage(FDoc.Pages[5]); // get our page reference
  { call a custom draw function from our custom class }
  P.DrawRoundedRect(...);


I'll send the changes to Michael so he can update fcl-pdf.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp




More information about the Lazarus mailing list