5

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?

3
  • 1
    This question isn't very clear, so you'll probably find it gets closed as a duplicate to Generate pdf from HTML in div using Javascript, Download a div in a HTML page as pdf using javascript or something similar. It seems that you want to save a PDF to your Google Drive, with the complete contents of a div from a page served by Google Apps Script's HtmlService. Commented Jul 6, 2015 at 12:39
  • 1
    try inline css inside the html Commented Jul 6, 2015 at 13:34
  • is it possible to convert pdf to html in the same way Commented Dec 16, 2021 at 15:02

1 Answer 1

0

the inline css will work when html is retrieved from jquery but the html view cannot be same in the pdf also. I had problems with alignment of the tables in pdf format.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.