0

I am receiving a byte stream by calling a rest endpoint which represents a pdf, and this pdf is just a template with placeholders for fields like firstName, lastName etc. Now I want to play with the byte stream (convert to some object maybe?) and populate fields like firstName, lastName and then convert the formatted thingy back to bytestream and send to UI.

  1. Is it even possible?
  2. How to start with, is there any tool available for that? Like pdfbox

Any help would be appreciated

Abhijeet Ahuja
  • 5,596
  • 5
  • 42
  • 50
  • Yes, this is possible with PDFBox, if the fields are AcroForn fields. Yes PDFBox can read the byte stream, set the fields, and save it into a byte output stream. In the PDFBox source download, go to the directory org.apache.pdfbox.examples.interactive.form in the examples subproject. – Tilman Hausherr May 02 '17 at 01:38
  • Abhijeet, as you formulate your requirements, any decent general purpose pdf library should be usable. – mkl May 02 '17 at 06:42
  • @mkl Should I consider some expression languages, like apache jexl? – Abhijeet Ahuja May 02 '17 at 06:47
  • *"Should I consider some expression languages, like apache jexl"* - no, use a decent general purpose pdf library. E.g. PDFBox. – mkl May 02 '17 at 07:48
  • See this answer for how to fill forms. http://stackoverflow.com/a/29417945/535646 , assuming your forms are AcroForm and not XFA. Re "expression language", be aware that PDF isn't something like HTML. Open a PDF with a text editor and you'll understand. – Tilman Hausherr May 02 '17 at 10:53

0 Answers0