hajareshyam / pdf-creator-node

This package is used to generate HTML to PDF in Nodejs
MIT License
238 stars 80 forks source link

Render HTML in landscape desktop mode #64

Open benripka opened 2 years ago

benripka commented 2 years ago

Hi there, I'm looking to get a PDF generated from the HTML of my website which uses bootstrap and is responsive to displays size. I'm finding that the node-pdf-creator always renders it in it's mobile mode. Is there any options / suggestions on how to force the creator render the HTML + CSS in desktop mode?

I have tried setting the width and height very wide, and using landscape mode to no avail. Any help would be appreciated.

Here is my generation script, without templating data yet:

import * as fs from "fs";

// Read HTML Template
let html = fs.readFileSync('template.html', 'utf8')

let options = {
    orientation: "landscape",
    height: "20in",
    width: "40in",
}

let document = {
    html: html,
    data: {
        inspection: [],
        photos: []
    },
    path: "./output.pdf"
};

pdf.create(document, options)
    .then(res => {
        console.log(res)
    })
    .catch(error => {
        console.error(error)
    });
noudadrichem commented 2 years ago

+1 for this...