SudoSOS Back-end API / internal/pdf / HtmlPdfService
Abstract Class: HtmlPdfService<S, T, P> ​
HTML-to-PDF service for entities that store PDFs. Similar to PdfService but uses HTML templates instead of LaTeX.
Extends ​
BaseHtmlPdfService<T,P>
Type Parameters ​
| Type Parameter | Default type |
|---|---|
S extends Pdf | - |
T extends IPdfAble<S> | - |
P extends PdfTemplateParameters | PdfTemplateParameters |
Implements ​
IStoredPdfService<T,S>
Constructors ​
Constructor ​
ts
new HtmlPdfService<S, T, P>(fileLocation, manager?): HtmlPdfService<S, T, P>;Parameters ​
| Parameter | Type |
|---|---|
fileLocation | string |
manager? | EntityManager |
Returns ​
HtmlPdfService<S, T, P>
Overrides ​
BaseHtmlPdfService.constructor
Properties ​
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
client | protected | Client | - | BaseHtmlPdfService.client |
fileService | public | FileService | - | - |
htmlGenerator | abstract | HtmlGenerator<P> | The function that generates the HTML. This function should take a data object and return the complete HTML string. | BaseHtmlPdfService.htmlGenerator |
htmlPdfGenUrl | protected | string | - | BaseHtmlPdfService.htmlPdfGenUrl |
manager | protected | EntityManager | - | BaseHtmlPdfService.manager |
pdfConstructor | abstract | () => S | - | - |
Methods ​
compileHtml() ​
ts
protected compileHtml(html): Promise<Buffer<ArrayBufferLike>>;Compile HTML to PDF using the external service.
Parameters ​
| Parameter | Type |
|---|---|
html | string |
Returns ​
Promise<Buffer<ArrayBufferLike>>
Inherited from ​
BaseHtmlPdfService.compileHtml
createPdfBuffer() ​
ts
createPdfBuffer(entity): Promise<Buffer<ArrayBufferLike>>;Create a PDF and return bytes.
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<Buffer<ArrayBufferLike>>
Inherited from ​
BaseHtmlPdfService.createPdfBuffer
createPdfWithEntity() ​
ts
createPdfWithEntity(entity): Promise<S>;Persist the generated PDF and return the stored Pdf entity.
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<S>
Implementation of ​
IStoredPdfService.createPdfWithEntity
createRaw() ​
ts
createRaw(entity): Promise<Buffer<ArrayBufferLike>>;Create raw HTML output (for debugging or preview).
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<Buffer<ArrayBufferLike>>
Inherited from ​
getHtml() ​
ts
protected getHtml(entity): Promise<string>;Apply parameters to the template and return the complete HTML.
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<string>
Inherited from ​
getParameters() ​
ts
abstract getParameters(entity): Promise<P>;Get the data object to use with the HTML template.
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<P>