PDF Markings #114

Merged
eugene merged 33 commits from issue-99 into staging 2024-08-06 10:02:04 +00:00
Showing only changes of commit 0ba3ae14a4 - Show all commits

View File

@ -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;