spawnia/md-to-pdf

image width height is not respected

norama opened this issue · 2 comments

If width and height is specified as img attributes, PDF export does not respect this and exports image in its original size.
Example:

<img height="100" width="100" src="https://vegabox.hu/wp-content/uploads/2020/01/apples-poland-red-jonaprince-1-e1643214217535.jpg" />

However, if width and height are specified in CSS then it works:

img {
    width: 100px;
    height: 100px;
}

As I use this with an image inserting and resizing plugin which generates img with width and height attributes,
it would be nice to have PDF export respecting these attributes as well.

This project is a very thin wrapper around Pandoc, which handles the actual conversion from Markdown + CSS to PDF. The values given through the UI/API are passed to Pandoc untouched and the converted result is returned. See https://github.com/spawnia/md-to-pdf/blob/cfa24edcdea3110a981998fd9efb718752af1843/src/main.rs.

Thus, I am having a hard time imagining how to change the inner workings of the conversion to achieve the result you desire. It seems to me that it would involve some rather tricky manipulation of the passed Markdown/HTML and CSS. If you are really interested and can figure out an elegant solution, feel free to contribute.

Thanks for the quick answer, I will add some workaround in my project, using CSS.