diff --git a/README.md b/README.md index 797d749..b3d43dc 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ npm run push:docker [xlsx-template-next](https://www.npmjs.com/package/xlsx-template-next) ``` bash +cd test-run $ npx ts-node docx-template.ts Output extension(docx,pdf,odt): pdf JSON data path(./docx.json): diff --git a/libs/convert-libs.ts b/libs/convert-libs.ts index 61bce9f..fa2e5be 100644 --- a/libs/convert-libs.ts +++ b/libs/convert-libs.ts @@ -51,9 +51,14 @@ import { LibreOfficeFileConverter } from 'libreoffice-file-converter'; * schema: * type: string * format: binary - * text/html: + * image/png: * schema: * type: string + * format: binary + * image/jpeg: + * schema: + * type: string + * format: binary * 500: * description: Server error * diff --git a/libs/docx-templates-lib.ts b/libs/docx-templates-lib.ts index 70f1be9..9c60951 100644 --- a/libs/docx-templates-lib.ts +++ b/libs/docx-templates-lib.ts @@ -50,8 +50,6 @@ export async function docxTemplateX(base: string=".", tdata: templateData, outpu } - - /** javascript-obfuscator:disable * @swagger * /api/v1/report-template/docx: @@ -117,6 +115,14 @@ docxTemplateRoute.get("/", async function (req, res) { * schema: * type: string * format: binary + * image/png: + * schema: + * type: string + * format: binary + * image/jpeg: + * schema: + * type: string + * format: binary * 500: * description: Server error * diff --git a/libs/report-template.ts b/libs/report-template.ts index b2df2cf..6a19814 100644 --- a/libs/report-template.ts +++ b/libs/report-template.ts @@ -23,7 +23,9 @@ export function mimeToExtension(mime: string): string { "text/csv": "csv", "text/markdown": "md", "text/plain": "txt", - "application/rtf": "rtf" + "application/rtf": "rtf", + "image/png": "png", + "image/jpeg": "jpeg", } if (mimeList[mime]) { return mimeList[mime] diff --git a/libs/swagger-specs.json b/libs/swagger-specs.json index 4d07627..20cda84 100644 --- a/libs/swagger-specs.json +++ b/libs/swagger-specs.json @@ -85,6 +85,18 @@ "schema": { "type": "string" } + }, + "image/png": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "image/jpeg": { + "schema": { + "type": "string", + "format": "binary" + } } } }, @@ -185,6 +197,18 @@ "type": "string", "format": "binary" } + }, + "image/png": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "image/jpeg": { + "schema": { + "type": "string", + "format": "binary" + } } } }, @@ -301,6 +325,18 @@ "type": "string", "format": "binary" } + }, + "image/png": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "image/jpeg": { + "schema": { + "type": "string", + "format": "binary" + } } } }, diff --git a/libs/xlsx-template-lib.ts b/libs/xlsx-template-lib.ts index a22b793..52a1abb 100644 --- a/libs/xlsx-template-lib.ts +++ b/libs/xlsx-template-lib.ts @@ -104,6 +104,14 @@ xlsxTemplateRoute.get("/", async function (req, res) { * schema: * type: string * format: binary + * image/png: + * schema: + * type: string + * format: binary + * image/jpeg: + * schema: + * type: string + * format: binary * 500: * description: Server error * diff --git a/templates/xlsx/hello.xlsx b/templates/xlsx/hello.xlsx index ef0e136..b4efb0b 100644 Binary files a/templates/xlsx/hello.xlsx and b/templates/xlsx/hello.xlsx differ diff --git a/test-run/docx-template.ts b/test-run/docx-template.ts index 3c701df..ea91a2b 100644 --- a/test-run/docx-template.ts +++ b/test-run/docx-template.ts @@ -2,12 +2,12 @@ // 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 { docxTemplateX} from '../libs/docx-templates-lib'; +import {templateData} from '../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 e = await rl.question('Output extension(docx,pdf,odt,png,jpeg): '); const ext =e?e:"docx" const dpath = await rl.question('JSON data path(./docx.json): '); const datapath = dpath?dpath:"./docx.json" diff --git a/test-run/report-docx.jpeg b/test-run/report-docx.jpeg new file mode 100644 index 0000000..ffae476 Binary files /dev/null and b/test-run/report-docx.jpeg differ diff --git a/test-run/report-docx.png b/test-run/report-docx.png new file mode 100644 index 0000000..fc9722f Binary files /dev/null and b/test-run/report-docx.png differ diff --git a/test-run/report-xlsx.jpeg b/test-run/report-xlsx.jpeg new file mode 100644 index 0000000..341431e Binary files /dev/null and b/test-run/report-xlsx.jpeg differ diff --git a/test-run/report-xlsx.pdf b/test-run/report-xlsx.pdf index 5aecf85..ecad57b 100644 Binary files a/test-run/report-xlsx.pdf and b/test-run/report-xlsx.pdf differ diff --git a/test-run/report-xlsx.png b/test-run/report-xlsx.png new file mode 100644 index 0000000..99325e0 Binary files /dev/null and b/test-run/report-xlsx.png differ diff --git a/test-run/xlsx-template.ts b/test-run/xlsx-template.ts index 0a85219..a6780b3 100644 --- a/test-run/xlsx-template.ts +++ b/test-run/xlsx-template.ts @@ -2,12 +2,12 @@ // npx ts-node xlsx-template.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 {xlsxTemplateX} from '../src/libs/xlsx-template-lib' -import {templateData} from '../src/libs/report-template' +import {xlsxTemplateX} from '../libs/xlsx-template-lib' +import {templateData} from '../libs/report-template' import fs from 'fs'; (async ()=>{ 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 dpath = await rl.question('JSON data path(./xlsx.json): '); const datapath = dpath?dpath:"./xlsx.json"