pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

none of the file resources are getting recognized #23

Closed svlungade closed 8 years ago

svlungade commented 8 years ago

i used below code to replace the file names with absolute file path, still it is giving me protocol is unknown, i have font files, image files to include in pdf

var dirName = path.join('file://', __dirname);
dirName = dirName + '/';

html = html.replace(/src="/g, 'src="'+dirName).replace(/src: url(/g,'src: url('+dirName);

svlungade commented 8 years ago

sorry, i had to set the flag as true for allowLocalFilesAccess, it resolved the issue

conversion({ html: html, phantomPath: require("phantomjs-prebuilt").path,allowLocalFilesAccess: true }, function(err, pdf) {