5

I am working on mean stack project. In this i have a requirement to generate pdf dynamically and send it on the user email id. But pdf should be password protected when user enter the password he can see the content of pdf. I am using html-pdf node module for generating pdf but i don't have any idea how can i make it password protected. Please help me anyone.

Below is my code for generating pdf :

// This Is Use To Genrate Pdf.
    app.post("/upload", function(req, res) {
        var html = req.body.html;
        var loanId = req.body.loanid;
        var options = { format: 'Letter'};
        var pdfname = 'loan_'+loanId+'.pdf';
        pdf.create(html, options).toFile('../client/app/loanpdf/'+pdfname, function(err, res) {
          if (err) return console.log(err);
        });
        res.status(200).send({'pdfname':pdfname});
    });

Thanks in advance :)

stdob--
  • 28,222
  • 5
  • 58
  • 73
  • Usually this is done by coining a unique code for each generated PDF and stores it in a local database with a reference to the file that matches it. That code will be put in the URL you email the user. When the user clicks on the URL, your code looks up the code in a database and when it finds that code, it can then either directly provide access to the PDF file (using the generated code as the magic password) or it can then prompt the user for an additional password that is required before providing access to the file. – jfriend00 May 24 '16 at 07:18
  • Thanks for your reply. But there no any other option like i can embed password during pdf generation and when every time user open pdf it ask for password. Or any node module?? – Salman Ahmad - Mean Developer May 24 '16 at 07:47
  • you want to password protect he pdf(offline) or you just want to password protect he url from which the user will access the pdf(online). – Nivesh May 24 '16 at 07:49
  • Actually i am sending the pdf on user email . Actually its a bank website so i send the loan data in pdf format on there email. My requirenment is when user download there pdf and open it from attachment then first enter password which i set then he can view the pdf data. – Salman Ahmad - Mean Developer May 24 '16 at 07:54
  • Thanks to all for your effort but finally i found the solution after doing alots of googling. Here is the solution .. http://phpsollutions.blogspot.com/2016/05/how-to-do-pdf-password-protected-in.html – Salman Ahmad - Mean Developer Jun 02 '16 at 05:27

0 Answers0