Skip to content

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 ​

Type Parameters ​

Type ParameterDefault type
S extends Pdf-
T extends IPdfAble<S>-
P extends PdfTemplateParametersPdfTemplateParameters

Implements ​

Constructors ​

Constructor ​

ts
new HtmlPdfService<S, T, P>(fileLocation, manager?): HtmlPdfService<S, T, P>;

Parameters ​

ParameterType
fileLocationstring
manager?EntityManager

Returns ​

HtmlPdfService<S, T, P>

Overrides ​

BaseHtmlPdfService.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
clientprotectedClient-BaseHtmlPdfService.client
fileServicepublicFileService--
htmlGeneratorabstractHtmlGenerator<P>The function that generates the HTML. This function should take a data object and return the complete HTML string.BaseHtmlPdfService.htmlGenerator
htmlPdfGenUrlprotectedstring-BaseHtmlPdfService.htmlPdfGenUrl
managerprotectedEntityManager-BaseHtmlPdfService.manager
pdfConstructorabstract() => S--

Methods ​

compileHtml() ​

ts
protected compileHtml(html): Promise<Buffer<ArrayBufferLike>>;

Compile HTML to PDF using the external service.

Parameters ​

ParameterType
htmlstring

Returns ​

Promise<Buffer<ArrayBufferLike>>

Inherited from ​

BaseHtmlPdfService.compileHtml


createPdfBuffer() ​

ts
createPdfBuffer(entity): Promise<Buffer<ArrayBufferLike>>;

Create a PDF and return bytes.

Parameters ​

ParameterType
entityT

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 ​

ParameterType
entityT

Returns ​

Promise<S>

Implementation of ​

IStoredPdfService.createPdfWithEntity


createRaw() ​

ts
createRaw(entity): Promise<Buffer<ArrayBufferLike>>;

Create raw HTML output (for debugging or preview).

Parameters ​

ParameterType
entityT

Returns ​

Promise<Buffer<ArrayBufferLike>>

Inherited from ​

BaseHtmlPdfService.createRaw


getHtml() ​

ts
protected getHtml(entity): Promise<string>;

Apply parameters to the template and return the complete HTML.

Parameters ​

ParameterType
entityT

Returns ​

Promise<string>

Inherited from ​

BaseHtmlPdfService.getHtml


getParameters() ​

ts
abstract getParameters(entity): Promise<P>;

Get the data object to use with the HTML template.

Parameters ​

ParameterType
entityT

Returns ​

Promise<P>

Inherited from ​

BaseHtmlPdfService.getParameters