79752662

Date: 2025-09-01 14:55:29
Score: 0.5
Natty:
Report link

As @aliaksandr-s pointed out:

No, what you are trying to do is impossible. Browsers intentionally do not allow web pages to change print dialog settings. If what you want is a PDF then use a library to generate it on the Server/Client side.

He is correct, it's not possible to change Chrome's default print margin setting using JavaScript or CSS.

The best you can do is try to minimize margins:

@media print {
  @page { margin: 0; }
  html, body { margin: 0; padding: 0; }
}

But, if you did this server-side, you could set zero margins in the PDF. A example would be:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://examplecom', { waitUntil: 'networkidle0' });
  await page.pdf({
    path: 'output.pdf',
    margin: { top: 0, right: 0, bottom: 0, left: 0 },
    printBackground: true,
    format: 'A4'
  });
  await browser.close();
})();
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @aliaksandr-s
  • Low reputation (0.5):
Posted by: 0ro2