File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program to password protect a signed pdf file using itext pdfstamper

 
pavithra murthy
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please could anyone help me out ...i have written this code for digitally signing pdf. here
when i compile the code works fine but after running and entering a user id i get an exception

D:\password>java EncryptPDF
USERNAME:PASSWORD
Please enter your username
shiva
pavithra: pvm4kor
shompa: sos5kor
shiva: snk3kor
passwordsnk3kor
hello
Exception in thread "main" java.io.IOException: Bad user password
at com.lowagie.text.pdf.PdfReader.readDecryptedDocObj(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readDocObj(Unknown Source)
at com.lowagie.text.pdf.PdfReader.readPdf(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at com.lowagie.text.pdf.PdfReader.<init>(Unknown Source)
at EncryptPDF.main(EncryptPDF.java:85)




thanks in advance ...
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on line 85, I think you need to supply your user password:



according to the API, (http://1t3xt.info/api/com/lowagie/text/pdf/PdfReader.html) this should work:

 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Other Open Source Projects.
 
pavithra murthy
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friend ,

i modified the program and put the password in PDFReader . but that exception is not going ..bad user password...but however i am getting the protected signed pdf ....but am getting signature in only one pdf..
please could you help me out ..

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pavithra murthy wrote:i modified the program and put the password in PDFReader . but that exception is not going ..bad user password...but however i am getting the protected signed pdf ....but am getting signature in only one pdf..
please could you help me out ..


Hi I'm not clear on which error you are seeing now. Could you post the error output?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic