PDF/CSS transformation - width of images & borders

Post here questions and problems related to editing and publishing DITA content.
gszabo
Posts: 13
Joined: Wed Jan 25, 2023 1:15 am

PDF/CSS transformation - width of images & borders

Post by gszabo »

Hello,

In my customization of Oxygen's PDF/CSS transformation, the .css puts a border around all block images in fig elements:

Code: Select all

*[class ~= "topic/fig"] *[placement="break"][class ~= "topic/image"]{
    margin-top:0;
    border: 1px solid black;
    padding: 1em;
}
For some images, the right border is rendered well to the right of the image, resulting in weird-looking white space. See the image in the pdf in the attached .zip.

The image is an svg, which is also in the attached zip. Here is the DITA markup for the fig/image:

Code: Select all

            <fig id="fig_rrx_wbq_m1c">
                <title>RAM Mount</title>
                <image placement="break" id="image_srx_wbq_m1c"
                    href="graphics/RAM-mount_install.svg">
                    <alt>Shows the RAM mount.</alt>
                </image>
            </fig>
How I can specify CSS that ensures the border does not include all the white space?
rendering-issue_svg-borders.zip
(93.66 KiB) Downloaded 44 times
julien_lacour
Posts: 575
Joined: Wed Oct 16, 2019 3:47 pm

Re: PDF/CSS transformation - width of images & borders

Post by julien_lacour »

Hello,

One solution could be to set the image width based on DITA-OT extracted image width:

Code: Select all

@namespace dita-ot url('http://dita-ot.sourceforge.net/ns/201007/dita-ot');

*[class ~= "topic/fig"] *[class ~= "topic/image"] {
  margin-top: 0;
  border: 1px solid black;
  padding: 1em;
}
*[class ~= "topic/image"][dita-ot|image-width] {
  width: attr(dita-ot|image-width px);
}
Regards,
Julien
Post Reply