This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

someone help me to generate password protected pdf with below code

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone help to find the solution for below issue
Generating pdf with base64 String which generated through jasper report,I can make password protected in jrxml as well but i have different requirement so i can't keep there.
I want to make protected pdf while sending attachment only so i tried many possibilities like (pdf writer,streamer and all) but nothing worked.
Below code i used to generate pdf as attachment , i want to make that attachment as password protected.

 
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the basic objective is to send a PDF as an attachment? If so, what does JSON have to do with it? And what does base-64 have to do with it? Neither is required for that objective.

You mention something about passwords, but for sending something as an attachment it doesn't matter what the attachment data is, so I'm assuming that that, too, is not relevant.
 
ramesh jarabana
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i get the request from FE in JSON format , so used JSON to retrieve the attachment name and content . Coming to base 64 format , i am getting the content in base64 from the font end part.. So those two used to fetch the exact data of the attachment. So these two are not related to my requirement .

My requirement is converting base64  into a pdf as an attchment ,i succeded in this.So above given code is working fine.

Now, attached pdf should be secured so need to keep some password with PDFWriter or something else , could't able to find proper solution for this.
 
Tim Moores
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a writeup of how to encrypt and decrypt a PDF using the open source OpenPDF library: https://knpcode.com/java-programs/password-protected-pdf-using-openpdf-java/

Actually, example code is right here: https://github.com/LibrePDF/OpenPDF/blob/master/pdf-toolbox/src/main/java/com/lowagie/tools/EncryptPdf.java
 
ramesh jarabana
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gone through the examples but they are doing on top of physical pdf , in this case i dont have any physical PDF . Data will come from base64 string format.
 
Tim Moores
Saloon Keeper
Posts: 5809
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API of PdfReader - it can read from a byte[] or an InputStream as well, so it doesn't matter where the data is coming from.
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!