File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes iText - fillable PDF saved in hard-drive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "iText - fillable PDF saved in hard-drive" Watch "iText - fillable PDF saved in hard-drive" New topic
Author

iText - fillable PDF saved in hard-drive

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
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
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
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.)


Ping & DNS - my free Android networking tools app
Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iText - fillable PDF saved in hard-drive
 
Similar Threads
Class.forName()
FDF Toolkit
selectBooleanCheckbox and immediate tag
dynamic jsp forms?
Acroform