I use the html-pdf to convert index.html to pdf, but always showing loading, has any options of apidoc to avoid this.
Try opening index.html in a web browser, then print the page, but instead of selecting a printer, choose "Save to PDF".
html-pdf is a converter that uses phantomjs, but why not just use phantomjs to finish the job.
var phantom = require('phantom');
phantom.create().then(function (ph) {
ph.createPage().then(function (page) {
page.property('paperSize', {
format: 'A4',
});
page.open("./apidoc/index.html").then(function (status) {
setTimeout(function () {
page.render("./index.pdf").then(function () {
ph.exit();
});
}, 5000);
});
});
});
I have just started using wkhtmltopdf for this. It works but there is one annoying caveat. Because the documentation is rendered via javascript I have to run the command with a delay of 2s to allow it to load even for a hello world complexity document. For example:
wkhtmltopdf --javascript-delay 2000 index.html helloWorld.pdf
Most helpful comment
I have just started using wkhtmltopdf for this. It works but there is one annoying caveat. Because the documentation is rendered via javascript I have to run the command with a delay of 2s to allow it to load even for a hello world complexity document. For example: