diff --git a/src/utils/pdf.ts b/src/utils/pdf.ts index f2da806..70b6539 100644 --- a/src/utils/pdf.ts +++ b/src/utils/pdf.ts @@ -10,6 +10,18 @@ PDFJS.GlobalWorkerOptions.workerSrc = 'node_modules/pdfjs-dist/build/pdf.worker. * @constant {number} */ const SCALE: number = 3; +/** + * Defined font size used when generating a PDF. Currently it is difficult to fully + * correlate font size used at the time of filling in / drawing on the PDF + * because it is dynamically rendered, and the final size. + * This should be fixed going forward. + * Switching to PDF-Lib will most likely make this problem redundant. + */ +const FONT_SIZE: number = 40; +/** + * Current font type used when generating a PDF. + */ +const FONT_TYPE: string = 'Arial'; /** * Converts a PDF ArrayBuffer to a generic PDF File @@ -162,7 +174,8 @@ const hasValue = (mark: Mark): boolean => !!mark.value; */ const draw = (mark: Mark, ctx: CanvasRenderingContext2D) => { const { location } = mark; - ctx!.font = '20px Arial'; + + ctx!.font = FONT_SIZE + 'px ' + FONT_TYPE; ctx!.fillStyle = 'black'; const textMetrics = ctx!.measureText(mark.value!); const textX = location.left + (location.width - textMetrics.width) / 2;