Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
edited tags
Link
Mogsdad
  • 46k
  • 21
  • 167
  • 289
Source Link
Pavarine
  • 716
  • 3
  • 15
  • 31

App Script HTML to PDF

I'm using Google App Script and I want to convert the contents of a div in a pdf file. I'm trying:

function genPdf(html) { var blob = Utilities.newBlob(html, "text/html", "text.html"); var pdf = blob.getAs("application/pdf"); DriveApp.createFile(pdf).setName("text.pdf"); } 

The 'html' parameter of the function is passed with a

$('#container').html() 

The problem is when I get the html of the div with the Jquery's html() function, it returns me the html without the CSS styles and/or images.

I need to generate a PDF with exactly the same content of the div.

Any suggestions?