Grover / Puppeteer: When generating a PDF from an HTML page, the PDF file has an unwanted white border

691 Views Asked by At

I am using Grover / Puppeteer to convert an HTML page to a PDF.

The HTML page renders in the desired way.

But, when creating the PDF, there is a white border on the far right side of the page, which isn't there on the HTML page.

Screenshot of the PDF with white space on the right side


This is the portion of my page, which is positioned on the far right when rendered as a HTML page, but not when converted into a PDF:

<div class="inline-block overflow-hidden absolute top-0 right-0 w-[140px]">
 <div class="transform origin-top-left -rotate-45 bg-brand-primary h-[200px]">
 </div>
</div>

This is my grover.rb file:

# original resolution in HTML
width = 842
height = 595

Grover.configure do |config|
  config.options = {
    format: 'A4',
    landscape: true,
    print_background: true,
    wait_until: 'networkidle0',
    launch_args: \['--no-sandbox'\],
    viewport: {
     width:,
     height:
    },
    scale: 1 / 0.75
  }
end

I have tried adjusting the width, height, format and scale options in the grover.rb file and have also tried to modify the HTML (however, I suspect the issue lies in the options, as the HTML page renders as expected).

I expected the border to disappear... it didn't. Would appreciate any hints! :)

0

There are 0 best solutions below