Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues controlling header and footer styles using a stylesheet #111

Open
darcyowens opened this issue Feb 1, 2022 · 2 comments
Open

Issues controlling header and footer styles using a stylesheet #111

darcyowens opened this issue Feb 1, 2022 · 2 comments

Comments

@darcyowens
Copy link

Currently attempting to get styles applying to headers and footers using the API. I'm trying to use the examples given in this repo. Seems no style is applying, any insight or are headers and footers completely broken in v2 releases?

All I'm getting at the moment is a very small, illegible header.

Here's the code/stylesheet/header:

header.hbs

<h3>MDPDF - An elegant markdown to pdf converter</h3>

styles.css

h3 {
    font-size:60px;
    color: red;
}

index.js

let options = {
    source: pathname,
    destination: process.cwd() + "/" + pathname.replace('.md', '.pdf'),
    header: path.join(__dirname, 'header.hbs'),
    style: path.join(__dirname, 'styles.css'),
    pdf: {
        format: 'A4',
        orientation: 'portrait',
	quality: '100',
        header: {
            height: '20mm'
        },
        footer: {
            height: '20mm'
	},
        border: {
            top: '10mm',
	    left: '10mm',
            bottom: '10mm',
            right: '10mm'
        }
    }
};

mdpdf.convert(options).then((pdfPath) => {
    console.log('PDF Path', pdfPath);
}).catch((err) => {
    console.error(err);
})

Using mdpdf 2.1.2.

@elliotblackburn
Copy link
Owner

Sadly it's a deffiency in chrome's Puppeteer. MDPDF takes the markdown and converts it to HTML, and then uses Puppeteer to render the HTML and convert to a PDF. Puppeteer doesn't allow you to apply styles to heads and footers at the moment using CSS.

Previously in v1 we used PhantomJS which did allow this but that project is now deprecated and unmaintained so we had to make the shift to puppeteer despite this sadly.

I would suggest raising a ticket with Puppeteer to ask about it.

@LucaBlackDragon
Copy link

LucaBlackDragon commented Jun 27, 2024

Maybe one could use juice or inline-css to inline styles into the header/footer .hbs files before passing them to mdpdf (for inline-css, check this issue too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants