File

src/module/pdf/subservices/PDFGenerator.markdown.ts

Extends

PDFGenerator

Index

Properties
Methods

Constructor

constructor(markdownService: MarkdownService)
Parameters :
Name Type Optional
markdownService MarkdownService No

Methods

Public generatePDF
generatePDF(options: GeneratorOptions)
Inherited from PDFGenerator
Defined in PDFGenerator:15
Parameters :
Name Type Optional
options GeneratorOptions No
Returns : Promise<Buffer>
Protected Async generatePDFFromBodyContent
generatePDFFromBodyContent(body: string)
Inherited from PDFGenerator
Defined in PDFGenerator:31

Generates a PDF from the given body. The body gets put in an HTML wrapper first.

Parameters :
Name Type Optional Description
body string No

Body content to be put in the PDF as HTML body.

Returns : Promise<Buffer>

Buffer containing the generated PDF.

Private Static getCustomCSS
getCustomCSS()
Inherited from PDFGenerator
Defined in PDFGenerator:114
Returns : string

Some small customizations to the GitHub markdown CSS.

Private Async getGithubMarkdownCSS
getGithubMarkdownCSS()
Inherited from PDFGenerator
Defined in PDFGenerator:88
Returns : Promise<string>

The GitHub markdown CSS.

Private Async getHighlightCSS
getHighlightCSS()
Inherited from PDFGenerator
Defined in PDFGenerator:95
Returns : Promise<string>

The HighlightJS CSS.

Private Async loadCSSFile
loadCSSFile(moduleName: string)
Inherited from PDFGenerator
Defined in PDFGenerator:99
Parameters :
Name Type Optional
moduleName string No
Returns : Promise<string>
Private Async putBodyInHTML
putBodyInHTML(body: string)
Inherited from PDFGenerator
Defined in PDFGenerator:69

Puts the given body in corresponding a <body> element. The returned string is a complete HTML "file" with slightly customized GitHub Markdown CSS.

Parameters :
Name Type Optional Description
body string No

Body to embed in HTML.

Returns : Promise<string>

Complete HTML "file" which contains the given body as body.

Properties

Private Readonly logger
Default value : new Logger(PDFGenerator.name)
Inherited from PDFGenerator
Defined in PDFGenerator:13
import { Injectable } from '@nestjs/common';
import { MarkdownService } from '../../markdown/markdown.service';
import { PDFGenerator } from './PDFGenerator.core';

interface GeneratorOptions {
    markdown: string;
}

@Injectable()
export class MarkdownPDFGenerator extends PDFGenerator<GeneratorOptions> {
    constructor(protected readonly markdownService: MarkdownService) {
        super();
    }

    public generatePDF(options: GeneratorOptions): Promise<Buffer> {
        const body = this.markdownService.generateHTMLFromMarkdown(options.markdown);

        return this.generatePDFFromBodyContent(body);
    }
}

results matching ""

    No results matching ""