Forum How do I...?

Embedding svg at its natural size

tech-no-logical
hi,

I have an externally produced svg file, with a natural width set to 16cm. if I embed this in a html file, and set prince's @page definition to A4 (210mm wide) and margins of 2.5cm on both sides, I expect this svg file to fit exactly. however, in the output, the image is scaled to 16/21 of its width, regardless of the shrink-to-fit setting. this causes the font-sizes in the svg to not match the font-sizes in the rest of the html (and thus the pdf).

setting the margins to 0 makes it work, but messes up the rest of the document.

is there a way to fix thise, other than scaling the svg by 131.25% to offset the shrinkage ?

tried with prince 9 (which we have in production) and prince 11. if you need more info, please ask.
mikeday
It works for me like this:
<style>
@page {
    size: A4;
    margin: 2.5cm;
    background: yellow
}
body { background: aqua }
</style>
<svg width="16cm" height="16cm" viewBox="0 0 100 100">
<rect fill="blue" stroke="red" x="0" y="0" width="100" height="100"/>
</svg>

Does your SVG resemble this approach?
tech-no-logical
that worked for me too. going back to the generated svg, I noticed that although its content was 16cm wide, the total width was set to 20cm in the svg itself. going back to fix that now, I'm pretty sure that was the culprit.

thanks for the consise example :)