Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iText - fillable PDF saved in hard-drive

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to save PDF (with all the fields fillable) in hard-drive, instead of streaming to browser. All the fields in the PDF are fillable. These fileds get populated programatically with values. In the future, this populated PDF (which is also fillable) could be opened from hard-drive using CutePDF for further editing.

I get NullPointerException in line below. filedName and fieldValue are not null.

acroFields.setField(fieldName, fieldValue);

No error message is shown in the Exception itself.

Any suggestion will be appreciated.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get NullPointerException in line below. filedName and fieldValue are not null.

acroFields.setField(fieldName, fieldValue);

In that particular line? Or is there a stack trace that points to something that gets called by "setField"? If not, is "acroFields" null? (It's probably blatantly obvious that it isn't, but just to make sure.)
 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, neither of these variables are null. The acrofields itself is not null. Nor the variables (filed and value) atre null. It throws only NullPointerException. No exception message is being thrown. And the exception is thrown by that line only.

I can successfully save PDF into hard-drive using iText bif and only if the fileds are non-editable (meaning that all the fields are set as partialFormFlattening as true. However, if this flag is set as false (meaning, fields are editable), I get exception in the line above.

With other variation of code (all the fields are still editable), I had NullPointer exception being thrown when trying to call close() on PDFStamper. PDFStamper itself was not null.

I am wondering it using iText API, if it is possible to save PDF form, if all the PDF fields are editable.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if I had to choose between the theories (1) the acroFields variable is null, or (2) there is a mysterious design fault which causes NullPointerException to be thrown for no reason, then I would go with (1) every time.

The other theory I might follow up is that the exception is actually being thrown by a different line of code. I wouldn't bother with any theories which said that somebody else's code was at fault until I had excluded all possibility of my code being at fault.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic