Attach the image to an existing PDF file in the right place

So, here, we have a bunch of PDF forms for users on our website to fill out, we have a submit button inside each pdf form that sends the completed data using the http post method. We already fill out a pre-filled form, where the user fills in general information about the html form, the data that is used to create partially filled several PDF files, therefore, regardless of which PDF form the user chose to fill out, they will all be regenerated with pre-filled filled with the information that he just printed in html form. I accomplish this using pdftk ( http://www.pdflabs.com/docs/pdftk-man-page/ ), which allows me to simply do this. But we come to make it more efficient, the user should be able to draw his signature on the html side at the pre-filled form stage , so we use signatures for this ( http://thomasjbradley.ca/lab/signature-pad/ ) than we create the image from the canvas created by the plugin. But since each PDF has its own signature position, we must insert the placeholder in pdf, which will be replaced for the signature image . Therefore, I came up with the idea of โ€‹โ€‹creating a disabled pdf text field with the name "signature", so through the nodejs application with the pdf2json module ( https://github.com/modesty/pdf2json ) I can parse the pdf form and get the position (x, y, w, h) of this particular field, being able to attach an image to a text field placeholder. So the problem is that pdftk does not support the attachment of an image to an existing PDF file or even attaches it at a specific position, I tried to find a nodejs module that would allow me to do this, but the only worthy nodejs module I found was pdfkit ( http://pdfkit.org/ ), but it only works with creating a new pdf , without editing the output, I looked at the pdfkit source code and I dropped it because I understand that it does not work in my case with the existing pdf . So, I got to the end, got to the final stage of this implementation, came to the last step to get this work, and I'm just a stack.

This is the result that I get from the pdf2json module for nodejs, which helps with the substitution of substitutions.

{ page: 7, index: 317, name: 'signature', type: 'alpha', x: 43.806640625, y: 14.64195833333333, w: 30.546828125000005, h: 1.9339166666666756 } 

If someone knows a server application that I could run with the unix command on my server to attach an image to an existing PDF, it will fit my needs, it does not have to be a host. p>

Observatory: I have already tested this adobe echosign product, but it does not meet our needs, it is not free and does not solve our problem of attaching a signature to several PDF files from one HTML form.

+6
source share
1 answer

I understand that I can use the nodejs pdfkit module to create a new clean PDF file with the signature in the correct position and just above two pdf files that have a clean pdf code with the signature image on top, like a stamp. I could do this using pdftk on the command line:

 pdftk form.pdf stamp signature.pdf output form-signed.pdf 

There is another free application tool like pdftk that I just found out and that is pdfjam. In addition, if you cannot use the nodejs pdfkit module (other than the pdfkt application) to create a new pdf image file in the right place, you have the stampTK tool ( http://www.pdflabs.com/tools/stamptk-the -pdf-stamp-maker / ), where you can analyze the command line image that will be printed in an existing pdf, but this tool is paid (not so much, and it costs), but since I have a pdfkit module for nodejs, which allows me to do just that with the pdfkt file, I use it and I also have more control over multiple signatures Module pdfkit for nodejs. Hope this answer helps someone.

+7
source

All Articles