0

I'm trying to generate PDF from the HTML I generate using angularjs but when I use the angular URL to request (via requestify) instead the content of the page, I'm getting the content of index.html page...does anyone know how to get the HTML content generate on the ng-view

$routeProvider .when('/mediakit/:account', { templateUrl: 'app/mediakit/mediakit.html', controller: 'MediaKitCtrl' });

I want the content from http://localhost:9000/mediakit/accountid that uses mediakit.html as template not the content of index.html (where the contents are load through ng-view)

The code I'm using to generate PDF

    let pdf = require('html-pdf');
      let requestify = require('requestify');
      let outputPath = './server/public/';
      //req.body.mediaKitURL --> is the URL that I load the content when I open in the browser
      requestify.get(req.body.mediaKitURL).then(function (response) {
        // Get the raw HTML response body
        let html = response.body; --> //the content here is the content from index.html, 
      //I would like to get the content from the my angular route that uses mediakit.html (same when I open the URL in the browser)
        let config = {format: 'letter'}; 

    // Create the PDF
        pdf.create(html, config).toFile(outputPath + '/media_kit_'+req.params.account+'.pdf', function (err, result) {
          if (err) return console.log(err);
          console.log(result); // { filename: '/pathtooutput/generated.pdf' }
          res.status(200).json();
        });
      });

I hope that's clear...

1 Answer 1

1

I think you are searching for pdf viewer to show generated pdf file content.

for that,plz refere below angularjs directive,

https://github.com/legalthings/angular-pdfjs-viewer

Sign up to request clarification or add additional context in comments.

1 Comment

this is not what I'm looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.