[Gambas-user] Anotating a pdf image

Tobias Boege taboege at ...626...
Fri Jan 10 21:57:52 CET 2014


On Fri, 10 Jan 2014, bill-lancaster wrote:
> I have a number of files in pdf format and I'd like to add some text to the
> image and save as a pdf file.
> Is this possible?
> If so, some hints as to how would be appreciated.
> 

Hmm. I've personally used a tool called pdftk for manipulating PDFs - but it
was at least time consuming to install on Arch Linux but that's what we love
Arch for, isn't it? :-) Anyway, seems that it's not suitable for your purpose
and I see a pure Gambas way, too:

 - Instantiate a new Image[], named myNewPdfImages, which will contain your
   new annotated pages as Image objects;
 - Define some Annotate() method (just for the purpose of this algorithm)
   which takes a pristine Image, annotates (using Paint) and then returns it;
 - Use gb.pdf. Load your PDF and loop through the pages:

   For iInd = 0 To myPdf.Count - 1
     myNewPdfImages[iInd] = Annotate(myPdf[iInd].GetImage())
   Next

   The key is myPdf[iInd].GetImage() to get an image of the iInd-th page;
 - Now use gb.cairo or the like to coalesce your new Images into a new PDF.

Nice application by the way. I can't wait to write it myself :-)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list