electron-html-to icon indicating copy to clipboard operation
electron-html-to copied to clipboard

zoomFactor doesn't seem to change the output of pdf rendered

Open a0js opened this issue 8 years ago • 2 comments

I've been experimenting with this fantastic module, but I can't seem to get the zoom factor to work. (I'm attempting to get 100px per inch on a Letter size pdf). Logs are printing the following when I try a zoomFactor of 3.0

electron-html-to:electron-log [Worker 8fd99f30-2dc5-11e6-b9c6-079a8d60bf2a] +1ms creating new browser window with options: { width: 600, height: 600, webPreferences: { nodeIntegration: false, javascript: true, webSecurity: false, zoomFactor: 3, preload: '/Volumes/code/pdfaas/node_modules/electron-html-to/lib/scripts/preload.js' }, show: false }

But the resulting pdf is the same as when the zoomFactor is 1. Any guidance would be greatly appreciated.

a0js avatar Jun 08 '16 23:06 a0js

@a0js hmmm it should work 😄 do you have some code/repository to play with it? also what version of electrondo you have installed?

one tip: you can activate the ELECTRON_HTML_TO_DEBUGGING=true env var to see the BrowserWindow of electron

bjrmatos avatar Jun 09 '16 01:06 bjrmatos

Below is the object I'm sending into the converter. I'm using the electron-prebuilt package ver. 1.2.2. When I activate the BrowserWindow, it does appear to be larger, yet when printing the page, the zoom doesn't seem to be applied, and it's printing the same size. This might be an issue with the browser rather than your module though.

EDIT: I'm using a Mac, I wonder if the system print settings are pulled into electron. When I zoom in on Chrome and do a print preview, the scaling isn't right either.

{ "html":"<html><head><link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'><style>html,body,div{font-family:'Open Sans',serif;padding:0;margin:0} div{background:repeating-linear-gradient(0deg,#606dbc,#606dbc 50px,#465298 50px,#465298 100px);height:1100px;overflow:hidden}</style></head><body><div>Hello World</div></body></html>", "browserWindow":{ "webPreferences":{ "zoomFactor":3 } }, "pdf":{ "pageSize":"Letter", "printBackground":true, "marginsType":1 } }

a0js avatar Jun 22 '16 16:06 a0js