go-pdf / fpdf

A PDF document generator with high level support for text, drawing and images
MIT License
540 stars 48 forks source link

How to Draw on Existing PDF #43

Open abhilashsajeev opened 1 year ago

abhilashsajeev commented 1 year ago

The examples in documentation shows adding new pdfs only. I would like to add lines and curves to existing pdf file. Could you please provide minimal working example of doing the same

sbinet commented 1 year ago

as of now, go-pdf/fpdf can only create PDFs from scratch. to achieve what you want, one would need to add infrastructure and code that reads+parses PDFs and then produces a Fpdf document (on top of which one would add new instructions).

I am not against adding such capabilities, but that's a bit outside of the current amount of time I can dedicate to go-pdf/fpdf. (but I do accept PRs, though.)

gedw99 commented 1 year ago

Can I suggest the htmx pattern .

it allows you to do pressure enhancement . What does that mean ?

Basically you can add more content to an existing file. It’s used normally for html when you want to change the dom nodes and inject new dom

So it’s a way to add more to a pdf basically

what I don’t know is if the pdf format gives a type of selector / dom where you can add / overwrite existing pdf like you can do with html ??

If there is then it’s a great way to make pdfs editable

rorycl commented 4 months ago

Assuming go-pdf/fpdf maintains some compatibility with jung-kurt/gofpdf, drawing on the pdf is quite simple.

Check out this example which draws vectors from a remarkable tablet .rm file onto a new layer of a pdf.