fix libs location in test-run,add jpeg png support
This commit is contained in:
parent
8c3790bead
commit
e43fabb216
14 changed files with 68 additions and 10 deletions
|
|
@ -51,6 +51,7 @@ npm run push:docker
|
||||||
[xlsx-template-next](https://www.npmjs.com/package/xlsx-template-next)
|
[xlsx-template-next](https://www.npmjs.com/package/xlsx-template-next)
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
|
cd test-run
|
||||||
$ npx ts-node docx-template.ts
|
$ npx ts-node docx-template.ts
|
||||||
Output extension(docx,pdf,odt): pdf
|
Output extension(docx,pdf,odt): pdf
|
||||||
JSON data path(./docx.json):
|
JSON data path(./docx.json):
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,14 @@ import { LibreOfficeFileConverter } from 'libreoffice-file-converter';
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
* format: binary
|
* format: binary
|
||||||
* text/html:
|
* image/png:
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
|
* format: binary
|
||||||
|
* image/jpeg:
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* format: binary
|
||||||
* 500:
|
* 500:
|
||||||
* description: Server error
|
* description: Server error
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ export async function docxTemplateX(base: string=".", tdata: templateData, outpu
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** javascript-obfuscator:disable
|
/** javascript-obfuscator:disable
|
||||||
* @swagger
|
* @swagger
|
||||||
* /api/v1/report-template/docx:
|
* /api/v1/report-template/docx:
|
||||||
|
|
@ -117,6 +115,14 @@ docxTemplateRoute.get("/", async function (req, res) {
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
* format: binary
|
* format: binary
|
||||||
|
* image/png:
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* format: binary
|
||||||
|
* image/jpeg:
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* format: binary
|
||||||
* 500:
|
* 500:
|
||||||
* description: Server error
|
* description: Server error
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@ export function mimeToExtension(mime: string): string {
|
||||||
"text/csv": "csv",
|
"text/csv": "csv",
|
||||||
"text/markdown": "md",
|
"text/markdown": "md",
|
||||||
"text/plain": "txt",
|
"text/plain": "txt",
|
||||||
"application/rtf": "rtf"
|
"application/rtf": "rtf",
|
||||||
|
"image/png": "png",
|
||||||
|
"image/jpeg": "jpeg",
|
||||||
}
|
}
|
||||||
if (mimeList[mime]) {
|
if (mimeList[mime]) {
|
||||||
return mimeList[mime]
|
return mimeList[mime]
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,18 @@
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"image/png": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image/jpeg": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -185,6 +197,18 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "binary"
|
"format": "binary"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"image/png": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image/jpeg": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -301,6 +325,18 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "binary"
|
"format": "binary"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"image/png": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image/jpeg": {
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "binary"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,14 @@ xlsxTemplateRoute.get("/", async function (req, res) {
|
||||||
* schema:
|
* schema:
|
||||||
* type: string
|
* type: string
|
||||||
* format: binary
|
* format: binary
|
||||||
|
* image/png:
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* format: binary
|
||||||
|
* image/jpeg:
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* format: binary
|
||||||
* 500:
|
* 500:
|
||||||
* description: Server error
|
* description: Server error
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -2,12 +2,12 @@
|
||||||
// npx ts-node docx-templates.ts
|
// npx ts-node docx-templates.ts
|
||||||
import * as readline from 'node:readline/promises'; // This uses the promise-based APIs
|
import * as readline from 'node:readline/promises'; // This uses the promise-based APIs
|
||||||
import { stdin as input, stdout as output } from 'node:process';
|
import { stdin as input, stdout as output } from 'node:process';
|
||||||
import { docxTemplateX} from '../src/libs/docx-templates-lib';
|
import { docxTemplateX} from '../libs/docx-templates-lib';
|
||||||
import {templateData} from '../src/libs/report-template'
|
import {templateData} from '../libs/report-template'
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
const rl = readline.createInterface({ input, output });
|
const rl = readline.createInterface({ input, output });
|
||||||
const e = await rl.question('Output extension(docx,pdf,odt): ');
|
const e = await rl.question('Output extension(docx,pdf,odt,png,jpeg): ');
|
||||||
const ext =e?e:"docx"
|
const ext =e?e:"docx"
|
||||||
const dpath = await rl.question('JSON data path(./docx.json): ');
|
const dpath = await rl.question('JSON data path(./docx.json): ');
|
||||||
const datapath = dpath?dpath:"./docx.json"
|
const datapath = dpath?dpath:"./docx.json"
|
||||||
|
|
|
||||||
BIN
test-run/report-docx.jpeg
Normal file
BIN
test-run/report-docx.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
BIN
test-run/report-docx.png
Normal file
BIN
test-run/report-docx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
BIN
test-run/report-xlsx.jpeg
Normal file
BIN
test-run/report-xlsx.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
BIN
test-run/report-xlsx.png
Normal file
BIN
test-run/report-xlsx.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
|
|
@ -2,12 +2,12 @@
|
||||||
// npx ts-node xlsx-template.ts
|
// npx ts-node xlsx-template.ts
|
||||||
import * as readline from 'node:readline/promises'; // This uses the promise-based APIs
|
import * as readline from 'node:readline/promises'; // This uses the promise-based APIs
|
||||||
import { stdin as input, stdout as output } from 'node:process';
|
import { stdin as input, stdout as output } from 'node:process';
|
||||||
import {xlsxTemplateX} from '../src/libs/xlsx-template-lib'
|
import {xlsxTemplateX} from '../libs/xlsx-template-lib'
|
||||||
import {templateData} from '../src/libs/report-template'
|
import {templateData} from '../libs/report-template'
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
const rl = readline.createInterface({ input, output });
|
const rl = readline.createInterface({ input, output });
|
||||||
const e = await rl.question('Output extension(xlsx,pdf,ods): ');
|
const e = await rl.question('Output extension(xlsx,pdf,ods,png,jpeg): ');
|
||||||
const ext =e?e:"xlsx"
|
const ext =e?e:"xlsx"
|
||||||
const dpath = await rl.question('JSON data path(./xlsx.json): ');
|
const dpath = await rl.question('JSON data path(./xlsx.json): ');
|
||||||
const datapath = dpath?dpath:"./xlsx.json"
|
const datapath = dpath?dpath:"./xlsx.json"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue