Skip to content

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 ParameterDefault typeDescription
T-The entity type
P extends PdfTemplateParametersPdfTemplateParametersThe template parameters type

Implements ​

Constructors ​

Constructor ​

ts
new BaseHtmlPdfService<T, P>(manager?): BaseHtmlPdfService<T, P>;

Parameters ​

ParameterType
manager?EntityManager

Returns ​

BaseHtmlPdfService<T, P>

Overrides ​

WithManager.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
clientprotectedClient--
htmlGeneratorabstractHtmlGenerator<P>The function that generates the HTML. This function should take a data object and return the complete HTML string.-
htmlPdfGenUrlprotectedstring--
managerprotectedEntityManager-WithManager.manager

Methods ​

compileHtml() ​

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

Compile HTML to PDF using the external service.

Parameters ​

ParameterType
htmlstring

Returns ​

Promise<Buffer<ArrayBufferLike>>


createPdfBuffer() ​

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

Create a PDF and return bytes.

Parameters ​

ParameterType
entityT

Returns ​

Promise<Buffer<ArrayBufferLike>>

Implementation of ​

IPdfServiceBase.createPdfBuffer


createRaw() ​

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

Create raw HTML output (for debugging or preview).

Parameters ​

ParameterType
entityT

Returns ​

Promise<Buffer<ArrayBufferLike>>

Implementation of ​

IPdfServiceBase.createRaw


getHtml() ​

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

Apply parameters to the template and return the complete HTML.

Parameters ​

ParameterType
entityT

Returns ​

Promise<string>


getParameters() ​

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

Get the data object to use with the HTML template.

Parameters ​

ParameterType
entityT

Returns ​

Promise<P>

Implementation of ​

IPdfServiceBase.getParameters