AmirTugi / tea-school

Simplified HTML + CSS --> PDF Generator for Nodejs
343 stars 31 forks source link

styling and fonts don't work #11

Closed rugggger closed 5 years ago

rugggger commented 5 years ago

I'm using your package on node.js - running the following code :

const tea = require('tea-school');
const path = require('path');

exports.createtPDF = ()=> {
const options = {
    htmlTemplatePath: path.resolve(__dirname, 'pdf-template.pug'),
    styleOptions: {
        file: path.resolve(__dirname, 'pdf-template.scss')
    },
    htmlTemplateOptions: {
        contextRelatedVar: 'Timothy'
    },
    pdfOptions: {
        // Omit to get output as buffer solely
        path: 'pdf-file.pdf',
        format: 'A4',
        printBackground: true
    }
};
        tea.generatePdf(options).then((res) => {
            console.log('ready');

        });

}

The pug includes the styling:

style(type="text/css").

    * {
        color:blue;
        background: #e0e0e0;

    }
    p {
        font-family:  'Varela Round', sans-serif;
        color:green;
        text-align: center;

    }
    @font-face {
        font-family: 'Varela Round';
        src: url('VarelaRound-Regular.ttf');
    }

div#banner-message
    p Hello, #{name}
    p עברית שפה קשה
    button My god, this is amazing

Some of the styles work, but some don't. fonts don't show correctly, and if I add

p {
        background: #e0e0e0;
}

The entire pdf comes empty.

Am I using the package wrong ?