Apidoc: html to pdf

Created on 12 Apr 2018  路  3Comments  路  Source: apidoc/apidoc

I use the html-pdf to convert index.html to pdf, but always showing loading, has any options of apidoc to avoid this.

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:

wkhtmltopdf --javascript-delay 2000 index.html helloWorld.pdf

All 3 comments

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

a-tonchev picture a-tonchev  路  4Comments

tnunes picture tnunes  路  7Comments

ivan-kleshnin picture ivan-kleshnin  路  5Comments

reloaded picture reloaded  路  4Comments

dvv picture dvv  路  8Comments