SudoSOS Back-end API / internal/pdf / BaseHtmlPdfService
Abstract Class: BaseHtmlPdfService<T, P> ​
Base class for HTML-to-PDF services. Produces bytes via createPdfBuffer. Concrete stored services should implement createPdfWithEntity to persist and return the Pdf entity.
Templates are stored in static/pdf/ and use placeholders.
Extends ​
Extended by ​
Type Parameters ​
| Type Parameter | Default type | Description |
|---|---|---|
T | - | The entity type |
P extends PdfTemplateParameters | PdfTemplateParameters | The template parameters type |
Implements ​
Constructors ​
Constructor ​
ts
new BaseHtmlPdfService<T, P>(manager?): BaseHtmlPdfService<T, P>;Parameters ​
| Parameter | Type |
|---|---|
manager? | EntityManager |
Returns ​
BaseHtmlPdfService<T, P>
Overrides ​
Properties ​
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
client | protected | Client | - | - |
htmlGenerator | abstract | HtmlGenerator<P> | The function that generates the HTML. This function should take a data object and return the complete HTML string. | - |
htmlPdfGenUrl | protected | string | - | - |
manager | protected | EntityManager | - | WithManager.manager |
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>>
createPdfBuffer() ​
ts
createPdfBuffer(entity): Promise<Buffer<ArrayBufferLike>>;Create a PDF and return bytes.
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<Buffer<ArrayBufferLike>>
Implementation of ​
IPdfServiceBase.createPdfBuffer
createRaw() ​
ts
createRaw(entity): Promise<Buffer<ArrayBufferLike>>;Create raw HTML output (for debugging or preview).
Parameters ​
| Parameter | Type |
|---|---|
entity | T |
Returns ​
Promise<Buffer<ArrayBufferLike>>
Implementation of ​
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>
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>