mirind4
mirind4

Reputation: 1573

Figures does not appear in original size in pdf format converted by ReStructuredText

I am creating a documentation using ReStructuredText (rst) format. I convert the documentation to pdf format with this rst converter. When I try to link a figure, it does not appear in the original size of image in pdf format. All the displayed images are very small, but I use relative big images (.png and .jpg) for example with the width of 470px and height of 520px. If I multiply the width and the height of an image by three, it appears in the desired size, but I am of the opinion that it is not the proper way to solve this. I also tried to look for solution over the internet, but I have not found any. Would anyone be so kind as to help me in this matter? Thanks in advance!

Example code:

.. figure:: img/device_manager.jpg
    :align: center
    :alt: Run window
    :width: 470px
    :height: 520px
    :scale: 100

Upvotes: 2

Views: 415

Answers (1)

cweiske
cweiske

Reputation: 31088

This issue is described in the manual:

Images usually are measured in pixels, which are meaningless in a PDF. To convert between pixels and inches or centimeters, we use a DPI (dots-per-inch) value.

For example, 300 pixels, with a 300DPI, are exactly one inch. 300 pixels at 100DPI are 3 inches.

For that reason, to achieve a nice layout of the page, it's usually a good idea to specify the size of your images in those units, or as a percentage of the available width and you can ignore all this DPI nonsense ;-)

The rst2pdf default is 300DPI, but you can change it using the --default-dpi option or the default_dpi setting in the config file.

So simply lower the DPI you're using to produce the PDF.

Upvotes: 2

Related Questions