metanorma / metanorma-iso

Metanorma processor for ISO standards
BSD 2-Clause "Simplified" License
13 stars 5 forks source link

PDF: resize SVG image if overflow the page #1126

Closed Intelligent2013 closed 6 months ago

Intelligent2013 commented 6 months ago

Source issue: https://github.com/metanorma/metanorma/issues/357

From .pdf.err:

The contents of fo:region-body on page 34 exceed its viewport by 112605 millipoints. (See position 1:11612)
The contents of fo:region-body on page 32 exceed its viewport by 137355 millipoints. (See position 1:11612)

image

The Presentation XML:

<figure id="_5b7ffd44-a63f-ebd7-5b75-7661a64e1b23">
<name>Figure 17 — C2PA Manifest Store With an Ingredient</name>
<image src="" mimetype="image/svg+xml" height="1067px" width="488px"><svg xmlns="http://www.w3.org/2000/svg"

The image height is 1067px. The total page height is 297cm (11.7in). The effective page height is 297cm-25.5mm(bottom margin)-27.4mm(top margin)=244.1mm (9.6in) The Apache FOP image resolution is 96dpi (config):

<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
    <source-resolution>96</source-resolution>

I.e. the image height is 11.1in, i.e. not enough vertical space due the page margins - ~1.49in. (also there is Figure title)

Need resize the image width/height values via XSLT on-fly (it done already for some cases).

Intelligent2013 commented 6 months ago

Fixed: image