2

How is it possible to fill PDF input fields with javascript ( if it is even possible ). In my case I want to create a javascript in which I can fill a HTML form, the data which the user put in the HTML form should be saved into the PDF Input Field.

Thanks in advance.

2 Answers 2

3

I was looking on how to populate existing fields in a PDF with Node and after a while I found pdf-fill-form as a great option to do so.

And you can use it really easy

  // First get the Id of the value you need to populate in the pdf

  const pdfFillForm = require('pdf-fill-form');
  const fs = require('fs');
  let pdfFields = pdfFillForm.readSync('test/files/axapdf.pdf');
  console.log(pdfFields);

  var pdf = pdfFillForm.writeSync('pdf_to_fill.pdf',

    {'65536':'Set the value here'}, { "save": 'pdf' });


  fs.writeFileSync('filled_test_sync1.pdf', pdf);
Sign up to request clarification or add additional context in comments.

1 Comment

I was getting excited when I saw your answer. But the linked article says it is not supported on Windows. sadly.
0

you can use jpdf for the same, here is a fiddle demonstrating the same.

 var pdf = new jsPDF('p', 'mm', [297,210]);//page size
 var options = {
     pagesplit: true
    };
 pdf.addHTML($('#text_land')[0],options, function () {//data to print
 pdf.save('Test.pdf');
 });

study the fiddle, you must find what you are seeking for.

1 Comment

I believe the question is asking how to populate an input field in an existing PDF, rather than just draw the input into a PDF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.