Skip to content

Conversation

@chipta
Copy link

@chipta chipta commented Jan 12, 2016

Support relative link for html-pdf command.

This should fix #44 and #13.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I didn't know of that option.

@chipta
Copy link
Author

chipta commented Feb 12, 2016

@marcbachmann any updates?

@marcbachmann
Copy link
Owner

I've squashed that and merged into master. Thanks.

@marcbachmann
Copy link
Owner

I've just published that in html-pdf@2.0.0

@konstantinkrassmann
Copy link

Is there a example for this setting ?

@karex
Copy link

karex commented Feb 17, 2021

I've came across this "relative link"-issue, and found a working solution to create the base URL in the convert script, and it looks like this:

let path = require('path');
let currentPath = 'file:///' + path.resolve('.').replace(/\\/g, '/') + '/';

Then you can pass this base path to the pdf.create method in the options parameter like this:

let options = {
    format: 'A4',
    base: currentPath
};
pdf.create(html, options).toFile(pdfFile, function(err, res) {
    if (err) {
        return console.log(err);
    }
    console.log(res);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

image is not displayed after generating the pdf ?

4 participants