function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

send the password protection pdf via salesforce apex email to customer

when i am trying to create one email to send the pdf to the customer 
but, the customer ask I need a password pdf when I am clicking pdf will be ask password and open it .....any clue?
PriyaPriya (Salesforce Developers) 
Hi Prasanth,

Check below example that matches your requirement :-

Please mark it as the Best Answer so that it can help others in the future.


Priya Ranjan

Thanks for the reply
but how? archive this using Heroku any idea? give me
gvfdshg vgdfsgtfgvfdshg vgdfsgtf
If you are looking to send the password to the customer I will suggest you to take guide from here (  there are lots of solutions are avaialbel there.
Tony CantuTony Cantu
Yes, I would say that there are many kind of strategies which you can follow up to go for the next level of gaming experience such as where you can learn new articles about gaming and new moves will be shared for everybody anyway with full support
mukesh guptamukesh gupta
Hi Prasanath,

 Heroku can run java code and manipulate a pdf blob.

The final solution involved the following steps:
  • Salesforce generates the pdf, saves it as an attachment.
  • A workflow rule fires and invokes Heroku Java server via outbound messaging.
  • Record Id and Session Id are passed to Heroku server.
  • Heroku uses the Session Id and Record Id to query back the attachment data.
  • Java code is invoked on the attachment blob and password protects it.
  • The Attachment is saved back in Salesforce.
[snippet caption=”Java that runs on Heroku for password protection”]String desiredPassword = ‘“Topsecret”
try {
PdfReader pdfReader = new PdfReader(request.getInputStream());
PdfStamper pdfStamper = new PdfStamper(pdfReader ,resp.getOutputStream());
pdfStamper.setEncryption(desiredPassword.getBytes(), desiredPassword.getBytes(),
if(pdfStamper != null) {
try {
} catch (DocumentException e) {
throw e
} catch (Exception e) {
throw e;

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

erwgd hbgfhgferwgd hbgfhgf
To send the password you can visit on some related links like this ( and do this task in an easy way.