fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@design.estate/dees-document',
|
||||
version: '1.0.91',
|
||||
description: 'a catalog for creating documents like invoices'
|
||||
}
|
51
ts/classes.pdfservice.ts
Normal file
51
ts/classes.pdfservice.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import * as helpers from './helpers.js';
|
||||
|
||||
export interface IPdfServiceConstructorOptions {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* a pdf service for generating pdfs
|
||||
*/
|
||||
export class PdfService {
|
||||
// INSTANCE
|
||||
options: IPdfServiceConstructorOptions;
|
||||
|
||||
public smartpdfInstance: plugins.smartpdf.SmartPdf;
|
||||
|
||||
constructor(optionsArg: IPdfServiceConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* starts the PdfService
|
||||
*/
|
||||
public async start() {
|
||||
this.smartpdfInstance = new plugins.smartpdf.SmartPdf();
|
||||
await this.smartpdfInstance.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the PdfService
|
||||
*/
|
||||
public async stop() {
|
||||
await this.smartpdfInstance.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an letter
|
||||
*/
|
||||
public async createPdfFromLetterObject(letterDataArg: plugins.tsclass.business.ILetter) {
|
||||
const html = `
|
||||
<script type="module">
|
||||
${await helpers.getBundleAsString()}
|
||||
</script>
|
||||
<dedocument-dedocument printMode letterData="${plugins.smartjson.stringifyBase64(letterDataArg)}"></dedocument-dedocument>
|
||||
`;
|
||||
// console.log(html);
|
||||
const pdfResult = await this.smartpdfInstance.getA4PdfResultForHtmlString(html);
|
||||
return pdfResult;
|
||||
}
|
||||
}
|
6
ts/helpers.ts
Normal file
6
ts/helpers.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
|
||||
export const getBundleAsString = async () => {
|
||||
return plugins.smartfile.fs.toStringSync(paths.bundleFile);
|
||||
}
|
2
ts/index.ts
Normal file
2
ts/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './helpers.js';
|
||||
export * from './classes.pdfservice.js';
|
9
ts/paths.ts
Normal file
9
ts/paths.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||
|
||||
export const nogitDir = plugins.path.join(packageDir, '.nogit/');
|
||||
plugins.smartfile.fs.ensureDirSync(nogitDir);
|
||||
|
||||
export const bundleDir = plugins.path.join(packageDir, './dist_bundle');
|
||||
export const bundleFile = plugins.path.join(bundleDir, './bundle.js');
|
26
ts/plugins.ts
Normal file
26
ts/plugins.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
}
|
||||
|
||||
// @push.rocks/scope
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartjson from '@push.rocks/smartjson';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpdf from '@push.rocks/smartpdf';
|
||||
|
||||
export {
|
||||
smartfile,
|
||||
smartpath,
|
||||
smartjson,
|
||||
smartpdf,
|
||||
}
|
||||
|
||||
// @tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
}
|
Reference in New Issue
Block a user