Support TS, swagger,Template(xls,docx),PDF convert
This commit is contained in:
parent
b221deb1cf
commit
8d7654423a
84 changed files with 3604 additions and 1 deletions
21
test-run/docx-template.ts
Normal file
21
test-run/docx-template.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
// npx ts-node docx-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 { docxTemplateX} from '../src/libs/docx-templates-lib';
|
||||
import {templateData} from '../src/libs/report-template'
|
||||
import fs from 'fs';
|
||||
(async ()=>{
|
||||
const rl = readline.createInterface({ input, output });
|
||||
const e = await rl.question('Output extension(docx,pdf,odt): ');
|
||||
const ext =e?e:"docx"
|
||||
const dpath = await rl.question('JSON data path(./docx.json): ');
|
||||
const datapath = dpath?dpath:"./docx.json"
|
||||
const data_raw = fs.readFileSync(datapath);
|
||||
const tdata:templateData = JSON.parse(data_raw.toString());
|
||||
const bpath = await rl.question('Base path of templates-docx(..): ');
|
||||
const basepath = bpath?bpath:".."
|
||||
let buffer = await docxTemplateX(basepath,tdata,ext)
|
||||
fs.writeFileSync(tdata.reportName+"."+ext, buffer);
|
||||
rl.close();
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue