Page 1 of 1
Images in PDF scales and occupy full width of the page
Posted: Tue Dec 20, 2022 7:52 am
by manoj
I have an issue where the image on the PDF scales and takes the full available width of the page. I need the image to maintain its resolution and stop scaling. Is there any CSS rule to achieve this?
Re: Images in PDF scales and occupy full width of the page
Posted: Tue Dec 20, 2022 3:05 pm
by chrispitude
Hi Manoj,
Can you try setting the @width or @height attribute on the <image> element? This should allow you to control the image size. You can specify units, such as 4in or 200px.
You can also set the @scale attribute to a percentage value, to control size relatively instead of absolutely, such as setting it to 50 to make it half its original size.
Re: Images in PDF scales and occupy full width of the page
Posted: Tue Dec 20, 2022 3:49 pm
by julien_lacour
Hello,
Normally images should keep their original or scaled size (except if they are bigger than the page size), maybe you have a CSS rule setting their width to 100%.
For more information, you can also take a look at the
Images and Figures topic from our user-guide.
Regards,
Julien
Re: Images in PDF scales and occupy full width of the page
Posted: Wed Dec 21, 2022 12:35 am
by MichaelDa
Hi I am working with Manoj on the XML side of this. To add some detail, the issue where images are stretched to 100% is only happening in cases where there is a <fig> tag with a <title> tag.
So, images are stretched to 100% with XML coded this way...
<fig>
<title>Sample Image Title</title>
<image href="xyz.png"/></fig>
</fig>
But not when the XML is coded this way...
<fig>
<image href="xyz.png" placement="break"/>
</fig>
Is there some difference in the CSS containers associated with images with titles that might be causing the different behavior?
I should also note that in our Documentation, <fig> tags have titles when they are standalone images, but not when they are inline with other text, like procedures. So, the second example (where the stretching is not happening) is actually embedded inside of an ordered list, similar to the following...
<ol>
<li>...</li>
<li>...
<fig>
<image href="xyz.png" placement="break"/>
</fig>
</li>
</ol>
Re: Images in PDF scales and occupy full width of the page
Posted: Wed Dec 21, 2022 2:00 am
by chrispitude
Hi Michael,
I made a simple testcase but I cannot reproduce this behavior:
chemistry_image_size.zip
Are you setting the
@width,
@height, or
@scale attribute? Maybe your PNG file somehow does not have an intrinsic size defined? Maybe you could share a simple testcase that reproduces this behavior?
Note that even for
<image> elements in a
<fig>, I still set
@placement="break" so they are not treated as isolated inline elements. We did file an enhancement request (EXM-48437) for Oxygen to set
@placement="break" automatically when an image is inserted in a block-element context.
Re: Images in PDF scales and occupy full width of the page
Posted: Mon May 15, 2023 12:13 pm
by LASSE_MLE
Hi chrispitude,
To rebound in this topic, can you please explain how to force a scale tag for every illustration?
I tried using my CSS customization file but I did not have a scale parameter:
image.png
FYI, my idea is to set a scale to 99.9% to every illustrations so that, even if they have a correct displayable size, it creates the popup zoom capability

Thank you by advance for your help!
BR,
Mathieu
Re: Images in PDF scales and occupy full width of the page
Posted: Tue May 16, 2023 1:28 pm
by chrispitude
Hi Mathieu,
My guess is that you would need to add @scale in the DITA source so that publishing adds the correct CSS "zoom" properties in the output.
You could try using the
Add/Change attribute refactoring operation to do this, with something like the following:
Code: Select all
Element: image[not(@width or @height or @scale)]
Attribute local name: scale
Value: 99.9
I suggest trying this on a copy of your original fines in case the result is not what you expect.
- Chris
Re: Images in PDF scales and occupy full width of the page
Posted: Tue May 16, 2023 3:26 pm
by LASSE_MLE
Hi chrispitude,
Thank you for your answer. OK, I will try this.
It was my other plan. But I planned to do it brutally with Notepad++
Many tricks on Oxygen I still need to learn!
BR
Mathieu
Re: Images in PDF scales and occupy full width of the page
Posted: Tue May 16, 2023 3:54 pm
by chrispitude
Hi Mathieu,
Sometimes I preview XML refactoring operations just to see how much work they save me.
- Chris