asciidoctor-vscode
asciidoctor-vscode copied to clipboard
Can't render image in pdf with wkhtmltopdf 0.12.6
Description
with wkthmlttopdf 0.12.6, we must enable local file access to render images, this problem is discussed in https://stackoverflow.com/questions/62315246/wkhtmltopdf-0-12-6-warning-blocked-access-to-file.
May be this extension could add an option to supply arguments to wkthmltopdf?
That's a good idea, here's where we build the command line:
https://github.com/asciidoctor/asciidoctor-vscode/blob/ab1dc79924be9a0ee30326ebe11ed755f65f8f0f/src/commands/exportAsPDF.ts#L263-L270
Though, I wonder if wkthmlttopdf
will throw an error if we use this option on an older version? 🤔
Even with --enable-local-file-access
it won't work when using relative paths. Since we send the input content (HTML) as stdin, wkthmlttopdf
will create a temporary file at file:///tmp/test.html
and as a result relative paths won't work.
One way to solve this issue is to use data-uri
to embed images in the HTML. Another way is to configure the imagesdir
as an absolute path when exporting to PDF using wkthmlttopdf
. A third way would be to create a temporary HTML file in the same base directory.
In https://github.com/asciidoctor/asciidoctor-vscode/pull/587 I've added --enable-local-file-access
by default and also defined the Asciidoctor attribute data-uri
.