@medplum/core 0.9.9 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +19 -22
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +19 -22
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -820,12 +820,13 @@ function generatePdf(docDefinition, tableLayouts, fonts) {
|
|
|
820
820
|
docDefinition.defaultStyle.font = docDefinition.defaultStyle.font || 'Helvetica';
|
|
821
821
|
docDefinition.defaultStyle.fontSize = docDefinition.defaultStyle.fontSize || 11;
|
|
822
822
|
docDefinition.defaultStyle.lineHeight = docDefinition.defaultStyle.lineHeight || 2.0;
|
|
823
|
-
if (typeof pdfMake
|
|
824
|
-
return generatePdfServerSide(docDefinition, tableLayouts, fonts);
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
823
|
+
if (typeof window !== 'undefined' && typeof pdfMake !== 'undefined') {
|
|
827
824
|
return generatePdfClientSide(docDefinition, tableLayouts, fonts);
|
|
828
825
|
}
|
|
826
|
+
if (typeof process !== 'undefined' && typeof require !== 'undefined') {
|
|
827
|
+
return generatePdfServerSide(docDefinition, tableLayouts, fonts);
|
|
828
|
+
}
|
|
829
|
+
throw new Error('Unable to determine PDF environment');
|
|
829
830
|
});
|
|
830
831
|
}
|
|
831
832
|
function generatePdfServerSide(docDefinition, tableLayouts, fonts) {
|
|
@@ -838,27 +839,23 @@ function generatePdfServerSide(docDefinition, tableLayouts, fonts) {
|
|
|
838
839
|
italics: 'Helvetica-Oblique',
|
|
839
840
|
bolditalics: 'Helvetica-BoldOblique',
|
|
840
841
|
},
|
|
841
|
-
Roboto: {
|
|
842
|
-
normal: 'https://static.medplum.com/fonts/Roboto-Regular.ttf',
|
|
843
|
-
bold: 'https://static.medplum.com/fonts/Roboto-Medium.ttf',
|
|
844
|
-
italics: 'https://static.medplum.com/fonts/Roboto-Italic.ttf',
|
|
845
|
-
bolditalics: 'https://static.medplum.com/fonts/Roboto-MediumItalic.ttf',
|
|
846
|
-
},
|
|
847
|
-
Avenir: {
|
|
848
|
-
normal: 'https://static.medplum.com/fonts/avenir.ttf',
|
|
849
|
-
},
|
|
850
842
|
};
|
|
851
843
|
}
|
|
852
844
|
return new Promise((resolve, reject) => {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
845
|
+
try {
|
|
846
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
847
|
+
const PdfPrinter = require('pdfmake');
|
|
848
|
+
const printer = new PdfPrinter(fonts);
|
|
849
|
+
const pdfDoc = printer.createPdfKitDocument(docDefinition, { tableLayouts });
|
|
850
|
+
const chunks = [];
|
|
851
|
+
pdfDoc.on('data', (chunk) => chunks.push(chunk));
|
|
852
|
+
pdfDoc.on('end', () => resolve(concat(chunks)));
|
|
853
|
+
pdfDoc.on('error', reject);
|
|
854
|
+
pdfDoc.end();
|
|
855
|
+
}
|
|
856
|
+
catch (err) {
|
|
857
|
+
reject(err);
|
|
858
|
+
}
|
|
862
859
|
});
|
|
863
860
|
});
|
|
864
861
|
}
|