From b00b579f24223ccae1f3cf3d92c389f5ed6c5bec Mon Sep 17 00:00:00 2001 From: ledouxm Date: Tue, 12 Nov 2024 11:22:03 +0100 Subject: [PATCH] fix(pdf): blank page --- .../frontend/src/routes/pdf.$reportId.tsx | 1 + packages/pdf/src/report.tsx | 50 ++++++++++++++----- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/routes/pdf.$reportId.tsx b/packages/frontend/src/routes/pdf.$reportId.tsx index c5ca408..05e3f2b 100644 --- a/packages/frontend/src/routes/pdf.$reportId.tsx +++ b/packages/frontend/src/routes/pdf.$reportId.tsx @@ -427,6 +427,7 @@ const View = (props: ReportPDFDocumentProps) => { return blob; }, refetchOnWindowFocus: false, + enabled: !!props.htmlString, }); if (query.isLoading) return ; diff --git a/packages/pdf/src/report.tsx b/packages/pdf/src/report.tsx index e53f713..dee7e89 100644 --- a/packages/pdf/src/report.tsx +++ b/packages/pdf/src/report.tsx @@ -1,4 +1,4 @@ -import { Document, Font, Image, Page, View } from "@react-pdf/renderer"; +import { Document, Font, Image, Page, Text, View } from "@react-pdf/renderer"; import { Html } from "react-pdf-html"; import React from "react"; import type { Udap, Report, Service_instructeurs, Clause_v2, Pictures } from "@cr-vif/electric-client/frontend"; @@ -10,16 +10,18 @@ Font.registerHyphenationCallback((word) => { export const ReportPDFDocument = ({ udap, htmlString, images, pictures }: ReportPDFDocumentProps) => { return ( - + `} - {pictures ? ( - - {pictures - .filter((pic) => !!pic.url) - .map((pic) => ( - - ))} - - ) : null} + {pictures + ? pictures + .filter((pic) => !!pic.url) + .map((pic, index) => ( + 0} + style={{ + paddingTop: "48px", + paddingBottom: "32px", + maxHeight: "100vh", + }} + key={pic.id} + size="A4" + > + + + + + )) + : null} ); };