🐛(frontend) fix svg not rendering export pdf

The svg was not rendering in the pdf export.
We overwrite the default mapping to convert the
svg to png before rendering.
The images could be out of the page as well,
we fixed this issue by adding a maxWidth to the image.
This commit is contained in:
Anthony LC
2025-03-12 17:37:48 +01:00
committed by Anthony LC
parent cb8bd4b937
commit 0405e6a3f6
9 changed files with 220 additions and 27 deletions

View File

@@ -0,0 +1,8 @@
<svg width="100" height="100" viewBox="0 0 100 100">
<circle cx="50" cy="30" r="20" fill="#3498db" />
<polygon
points="50,10 55,20 65,20 58,30 60,40 50,35 40,40 42,30 35,20 45,20"
fill="#f1c40f"
/>
<text x="50" y="70" text-anchor="middle" fill="white">Hello svg</text>
</svg>

After

Width:  |  Height:  |  Size: 292 B

View File

@@ -157,11 +157,9 @@ test.describe('Doc Export', () => {
await page.getByText('Upload image').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(
path.join(__dirname, 'assets/logo-suite-numerique.png'),
);
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));
const image = page.getByRole('img', { name: 'logo-suite-numerique.png' });
const image = page.getByRole('img', { name: 'test.svg' });
await expect(image).toBeVisible();