Skip to content

The open alternative to Salesforce, designed for AI.

fix: images are not included in PDF exports (#16076)

Harshit Singha0491e4755f8
diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts
index 9f3bf0cee44..7841ae878dc 100644
--- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts
+++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/utils/exportBlockNoteEditorToPdf.ts
@@ -45,7 +45,34 @@ export const exportBlockNoteEditorToPdf = async (
initialContent: parsedBody,
});
- const exporter = new PDFExporter(editor.schema, pdfDefaultSchemaMappings);
+ const exporter = new PDFExporter(editor.schema, pdfDefaultSchemaMappings, {
+ resolveFileUrl: async (url: string) => {
+ try {
+ const response = await fetch(url, {
+ mode: 'cors',
+ credentials: 'omit',
+ });
+
+ if (!response.ok) {
+ throw new Error(
+ `Failed to fetch asset at ${url}: ${response.status} ${response.statusText}`,
+ );
+ }
+
+ return await response.blob();
+ } catch (error) {
+ if (
+ error instanceof Error &&
+ error.message.includes('Failed to fetch asset')
+ ) {
+ throw error;
+ }
+ throw new Error(
+ `Failed to fetch asset at ${url}: ${error instanceof Error ? error.message : 'Unknown error'}`,
+ );
+ }
+ },
+ });
const pdfDocument = await exporter.toReactPDFDocument(editor.document);