We try to use XsPDF basic library to fill fields on PDF document and then save the PDF out. More specific, I load a PDF document using your lib, change the values of the text boxes, then save the document to disk.
We use a PDF viewer to open the file and fields are filled as expected. Unfortunately, the fields leave empty if we use Acrobat Reader to open this PDF. It is really strange. The value in field will show if the field has focus. Once that field loses focus, the value disappears again. Would you please give us suggestions on this case. Thank you!
Answers
Hi,
We did some tests for filling your sample PDF forms and found that if we take the iref to the object referenced within one of text boxes, then use the object number of which to look up the object as a PDF dictionary within the document.internals.allobjects collection, the stream property contains all of the stream data. Please have a try.
One more thing you should know. This requires you to set the text rending position in the stream data. If you do not set it, the text will render below the actual text box. Our library provides the API to grab the text rendering position from the stream data of the source document which may help you produce the correct results. This is just a matter of apply a small regular expression to the string representation of the stream data, so should be easy.
Please let us know if it works or not. Contact us at anytime you need further help.
Thank you for your help. I have this working by following your suggestion. It is probably the best solution that i can be had for now.
That’s great! Hope this will help the original poster and maybe some others out there!