url 2 pdf support, update test run, reduse imge size,

This commit is contained in:
oom 2025-02-25 19:50:21 +07:00
parent e921875bde
commit f6b68e4379
32 changed files with 3851 additions and 1108 deletions

25
test-run/html-template.ts Normal file
View file

@ -0,0 +1,25 @@
// npx ts-node html-templates.ts
import * as readline from 'node:readline/promises'; // This uses the promise-based APIs
import { stdin as input, stdout as output } from 'node:process';
import { htmlTemplateX} from '../libs/html-templates-lib';
import {templateOption} from '../libs/report-template'
import fs from 'fs';
(async ()=>{
const rl = readline.createInterface({ input, output });
const e = await rl.question('Output extension(pdf,png,jpeg): ');
const ext =e?e:"pdf"
const dpath = await rl.question('JSON data path(./html.json): ');
const datapath = dpath?dpath:"./html.json"
const data_raw = fs.readFileSync(datapath);
const tdata:templateOption = JSON.parse(data_raw.toString());
const bpath = await rl.question('templates path(../templates/html): ');
const basepath = bpath?bpath:"../templates/html"
// const template = await fs.promises.readFile(`${basepath}/${tdata.template}.docx`)
let url = "https://bma-dashboard.frappet.synology.me/d/ANtkJay4z/4Lic4Li54LmJ4Lie4Li04LiB4Liy4Lij?orgId=1&kiosk"
//let url = "https://pantip.com"
// let url = "https://google.com"
let buffer = await htmlTemplateX(url, tdata,ext)
fs.writeFileSync(".output/"+tdata.reportName+"."+ext, buffer);
rl.close();
})()