Search code examples
xmlimagedocbook

How do I set a maximum image height in Docbook?


I'm currently having an issue that when I convert my docbook to pdf, the images are a tad wonky. 90% of my screenshots are fine, but the remainders have a height beyond 740 pixels and this causes them to run off the page. I'm having no problems with width.

<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook" xml:id="newNote">
  <title>New Note</title>
  <section>
    <title>Screenshot</title>
    <mediaobject>
      <imageobject>
        <imagedata fileref="./views/screenshots/newNote.png" scalefit="1" width="100%" contentdepth="100%"/>
      </imageobject>
    </mediaobject>
  </section>
</section>

I've tried contentdepth="740" and contentdepth="740px" width="100%" But no luck. I'm looking to tell the image to have a max height but fill out the width.


Solution

  • Without knowing what DocBook implementation you are using, I would recommend setting the height of the viewport area using the depth attribute (depth="740px") to make sure that the scaling works as expected. And try smaller values (ie. 320px) to make sure you are not overflowing the page size.

    If that doesn't do the trick, you may be experiencing a bug in the implementation.