@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/cjs/index.js
CHANGED
|
@@ -826,12 +826,13 @@
|
|
|
826
826
|
docDefinition.defaultStyle.font = docDefinition.defaultStyle.font || 'Helvetica';
|
|
827
827
|
docDefinition.defaultStyle.fontSize = docDefinition.defaultStyle.fontSize || 11;
|
|
828
828
|
docDefinition.defaultStyle.lineHeight = docDefinition.defaultStyle.lineHeight || 2.0;
|
|
829
|
-
if (typeof pdfMake
|
|
830
|
-
return generatePdfServerSide(docDefinition, tableLayouts, fonts);
|
|
831
|
-
}
|
|
832
|
-
else {
|
|
829
|
+
if (typeof window !== 'undefined' && typeof pdfMake !== 'undefined') {
|
|
833
830
|
return generatePdfClientSide(docDefinition, tableLayouts, fonts);
|
|
834
831
|
}
|
|
832
|
+
if (typeof process !== 'undefined' && typeof require !== 'undefined') {
|
|
833
|
+
return generatePdfServerSide(docDefinition, tableLayouts, fonts);
|
|
834
|
+
}
|
|
835
|
+
throw new Error('Unable to determine PDF environment');
|
|
835
836
|
});
|
|
836
837
|
}
|
|
837
838
|
function generatePdfServerSide(docDefinition, tableLayouts, fonts) {
|
|
@@ -844,27 +845,23 @@
|
|
|
844
845
|
italics: 'Helvetica-Oblique',
|
|
845
846
|
bolditalics: 'Helvetica-BoldOblique',
|
|
846
847
|
},
|
|
847
|
-
Roboto: {
|
|
848
|
-
normal: 'https://static.medplum.com/fonts/Roboto-Regular.ttf',
|
|
849
|
-
bold: 'https://static.medplum.com/fonts/Roboto-Medium.ttf',
|
|
850
|
-
italics: 'https://static.medplum.com/fonts/Roboto-Italic.ttf',
|
|
851
|
-
bolditalics: 'https://static.medplum.com/fonts/Roboto-MediumItalic.ttf',
|
|
852
|
-
},
|
|
853
|
-
Avenir: {
|
|
854
|
-
normal: 'https://static.medplum.com/fonts/avenir.ttf',
|
|
855
|
-
},
|
|
856
848
|
};
|
|
857
849
|
}
|
|
858
850
|
return new Promise((resolve, reject) => {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
851
|
+
try {
|
|
852
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
853
|
+
const PdfPrinter = require('pdfmake');
|
|
854
|
+
const printer = new PdfPrinter(fonts);
|
|
855
|
+
const pdfDoc = printer.createPdfKitDocument(docDefinition, { tableLayouts });
|
|
856
|
+
const chunks = [];
|
|
857
|
+
pdfDoc.on('data', (chunk) => chunks.push(chunk));
|
|
858
|
+
pdfDoc.on('end', () => resolve(concat(chunks)));
|
|
859
|
+
pdfDoc.on('error', reject);
|
|
860
|
+
pdfDoc.end();
|
|
861
|
+
}
|
|
862
|
+
catch (err) {
|
|
863
|
+
reject(err);
|
|
864
|
+
}
|
|
868
865
|
});
|
|
869
866
|
});
|
|
870
867
|
}
|