markdown-pdf
markdown-pdf copied to clipboard
Images not being shown in the runnings at all
A possible variation on #43. I have a script that uses a running script thus:
exports.header = {
height: '1in',
contents: function(pageNum, numPages) {
return '<img src="logo.jpg" height="39px" width="77px"><hr>';
}
};
It shows a blank image in the header. I've tried absolute paths as well (/path/to/logo.jpg) and altering the height, to no avail. Like #43 I then included the image in the text. No image appears, just a blank rectangle.
Any other HTML fragment in the running - text of various styles, even tables - works, but no images.
I would also like any information regarding this issue. If anyone as a solution, a fix or a workaround, you're welcome to share =)
+1 I can't get images to work either. Same blank rectangle regardless of what path I use.
+1 on this issues, any update on this? #43 workaround doesn't seem working for me.
any solution my runnings is not working at all , not even text is coming
If you are using ubuntu, I've just reported a bug with their phantomjs build https://bugs.launchpad.net/ubuntu/+source/phantomjs/+bug/1676518 Use the phantomjs binary provided by website to fix the header/footer problem : http://phantomjs.org/download.html
Still experiencing the same problem. unable to get the image in header & footer when header.contents returning from runnings.js. Anyone having luck in solving this issue.
Copy pasting the runnings.js example and using text only does allow to let the text pop up, but images are indeed not there.
@xxorax I just tried your suggestion, running on Ubuntu Bionic. When running your samples with the Ubuntu standard phantomjs, I receive two error messages:
TypeError: Attempting to change the setter of an unconfigurable property.
TypeError: Attempting to change the setter of an unconfigurable property.
The resulting output file does not have a footer.
When running with the binary downloaded from phantomjs.org, I don't see any errors and the output file has a footer.
So this is interesting and supports your understanding that something is wrong with the Ubuntu build of phantomjs 2.1.1.
However, at the same time the "official" version of phantomjs doesn't make any difference at all to the behavior in conjunction with markdown-pdf. Using the standard Ubuntu version, I can render headers and footers using runnings.js, and I don't get images rendered correctly in headers or footers. This behavior does not change at all when I use the --phantom-path
option with the "official" phantomjs build.
Anyone achieve add some header of footer without img? I can't add nothing. I've tried everything and I have to run this by node.
So, if everyone have and example with node adding a header to provide to me?
Hi, guys. I have pass through this by reading the phantomJS documentation. The PDF is assembledy asynchronously so you need to provide a preloaded image you could do that by adding a tag on the template file with the display set to none with the same address to the file that will by used at the runnings files.
At index.html file:
<img style='display: none' src='data:image/jpeg;base64.....' />
At runnings.js file:
exports.header = { height: '1cm' contents: function (pageNum, numPages) { return '<img src='data:image/jpeg;base64.....' />' } }
I also have some trouble with some formats of image so and could be solved parsing the image to the image64, but you will not have this problem with use an image from google images. If they have the problem with the image format could by solved using the link below to obtain the url. https://stackoverflow.com/questions/934012/get-image-data-url-in-javascript