Patch 0.0.2 #9

Merged
niggl merged 69 commits from dev into main 2021-02-03 17:24:35 +00:00
Showing only changes of commit 3fb8be22b7 - Show all commits

View File

@ -1,6 +1,8 @@
import fs from "fs";
import pdf_converter from "html-pdf";
import path from 'path';
import { Stream } from 'stream';
/**
* This class is responsible for all things pdf creation.
* This uses the html templates from src/templates.
@ -17,6 +19,10 @@ export class PdfCreator {
}
/**
* This class is a wrapper for the pdf objects created by html-pdf.
* It offers typed conversion to Buffer and Stream.
*/
export class Pdf {
content: any;
@ -27,9 +33,9 @@ export class Pdf {
/**
* Promise wrapper function that resolves the toBuffer promise for pdf generation.
*/
public async toBuffer(): Promise<any> {
let promise = await new Promise((resolve, reject) => {
this.content.toBuffer(function (err, buffer) {
public async toBuffer(): Promise<Buffer> {
let promise = await new Promise<Buffer>((resolve, reject) => {
this.content.toBuffer(function (err, buffer: Buffer) {
resolve(buffer);
});
});
@ -39,9 +45,9 @@ export class Pdf {
/**
* Promise wrapper function that resolves the toStream promise for pdf generation.
*/
public async toStream(): Promise<any> {
let promise = await new Promise((resolve, reject) => {
this.content.toStream(function (err, stream) {
public async toStream(): Promise<Stream> {
let promise = await new Promise<Stream>((resolve, reject) => {
this.content.toStream(function (err, stream: Stream) {
resolve(stream);
});
});