Images in PDF scales and occupy full width of the page

Post here questions and problems related to editing and publishing DITA content.
manoj
Posts: 1
Joined: Mon Dec 19, 2022 12:20 pm

Images in PDF scales and occupy full width of the page

Post 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?
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Images in PDF scales and occupy full width of the page

Post 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.
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Images in PDF scales and occupy full width of the page

Post 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
MichaelDa
Posts: 29
Joined: Fri Oct 14, 2011 3:41 am

Re: Images in PDF scales and occupy full width of the page

Post 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>
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Images in PDF scales and occupy full width of the page

Post by chrispitude »

Hi Michael,

I made a simple testcase but I cannot reproduce this behavior:

chemistry_image_size.zip
(6 KiB) Downloaded 164 times

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.
LASSE_MLE
Posts: 30
Joined: Mon Dec 05, 2022 3:24 pm

Re: Images in PDF scales and occupy full width of the page

Post 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
image.png (9.58 KiB) Viewed 846 times
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
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Images in PDF scales and occupy full width of the page

Post 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
LASSE_MLE
Posts: 30
Joined: Mon Dec 05, 2022 3:24 pm

Re: Images in PDF scales and occupy full width of the page

Post 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++ :wink:
Many tricks on Oxygen I still need to learn!
BR
Mathieu
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Images in PDF scales and occupy full width of the page

Post by chrispitude »

Hi Mathieu,

Sometimes I preview XML refactoring operations just to see how much work they save me. :)

- Chris
Post Reply