diff --git a/public/PDF/Template-EDV-ERT_v4.1.pdf b/public/PDF/Template-EDV-ERT_v4.1.pdf new file mode 100644 index 0000000..466768a Binary files /dev/null and b/public/PDF/Template-EDV-ERT_v4.1.pdf differ diff --git a/public/js/libProcessScript.js b/public/js/libProcessScript.js index b18c371..ebb4492 100644 --- a/public/js/libProcessScript.js +++ b/public/js/libProcessScript.js @@ -21,6 +21,9 @@ const dd = createDebugLogger(true, "dd"); // code function at bottom of the page // Wrapper function to fetch, update, and download PDF async function processAndDownloadPdf(filePath, ...dataSources) { + + dd(`Loaded PDF Template: ${filePath.value}`) + try { const pdfBytes = await fetchPdfBytes(filePath); const updatedPdfBytes = await updatePdfFields(pdfBytes, dataSources); @@ -56,26 +59,30 @@ async function updatePdfFields( dataSources, skipMissingFields = true ) { + console.log("Datasource size:", dataSources.length) try { const pdfDoc = await PDFLib.PDFDocument.load(pdfBytes); const form = pdfDoc.getForm(); dataSources.forEach((dataSource) => { + console.log("Current Datasource", dataSource) dataSource.forEach((record) => { - Object.entries(record).forEach(([fieldName, fieldValue]) => { + console.log("Working in: ", record) + Object.entries(record).forEach(([fieldName, fieldValue]) => { + dd(`Field: ${fieldName} Value: ${fieldValue}`) //debugger try { const formField = form.getTextField(fieldName); if (formField) { - console.info(`Field "${fieldName}" OK`); - dd(fieldName, "-->", fieldValue); + // console.info(`Field "${fieldName}" OK`); + dd(`${fieldName} --> ${fieldValue} OK`); formField.setText(String(fieldValue)); } else if (!skipMissingFields) { //dd(`Skipping Field: ${fieldName} NOT FOUND`) console.warn(`Field "${fieldName}" not found.`); } } catch (err) { - console.error(`Error updating field "${fieldName}":`, err); + console.error(`Error updating field "${fieldName}":`); //console.error(`Error updating field "${fieldName}":`, err); } }); }); diff --git a/public/listFields.html b/public/listFields.html new file mode 100644 index 0000000..887740e --- /dev/null +++ b/public/listFields.html @@ -0,0 +1,10 @@ + + + + +Untitled Document + + + + + diff --git a/views/layouts/main.ejs b/views/layouts/main.ejs index f6b3f0f..4963eda 100644 --- a/views/layouts/main.ejs +++ b/views/layouts/main.ejs @@ -52,12 +52,12 @@ - - - + + + - + @@ -67,7 +67,7 @@ - + diff --git a/views/observationPage.ejs b/views/observationPage.ejs index 39b88b6..43682a9 100644 --- a/views/observationPage.ejs +++ b/views/observationPage.ejs @@ -1,4 +1,4 @@ - + - + @@ -140,7 +140,9 @@ args: [ "{{ertTemplatePath.value}}", "{{datastore1.data}}", - "{{data_view1.data}}" + "{{data_view1.data}}", + "{{saveObservationResults.form2.getStartTime.value}}", + "{{saveObservationResults.form2.getEndTime.value}}" ] } } @@ -294,7 +296,6 @@
-
@@ -362,9 +363,6 @@ -
- -
@@ -392,6 +390,28 @@
+
+ + + + + + + + + + + + + + + + + + + +
$idDb full nameDb license numberDb state nameDb employee
+