Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node WebKit change print settings in source code

So I have an app built with node WebKit, it creates an image to be printed but I cannot get rid of all the margins by using CSS, so here is my CSS.

<style media="print">
  @page {
    size: 216mm 356mm;
    margin: 0; padding: 0;
    width: 216mm; height: 356mm;
  }

  html, body {
    margin: 0; padding: 0;
    width: 216mm; height: 356mm;
  }

  img {
    display: block;
    width: 100%; height: 100%;
  }
</style>

I've tried every combination of sizes, properties and hacks but there is still a huge margin/padding on the output. So since Node WebKit is open source I figured I'd put my C++ hat on and do it at a higher level.

Which of the many thousands of files in Node Webkit should I edit to remain forward compatible?

like image 222
Dave Mackintosh Avatar asked Mar 07 '26 12:03

Dave Mackintosh


1 Answers

I figured this out, after downloading the node-webkit source code and building a few times editing page-setup.cc::CalculateSizesWithinRect has allowed me to print without margins.

The source code now reads

void PageSetup::CalculateSizesWithinRect(const gfx::Rect& bounds, int text_height) {
  effective_margins_.header = 0;
  effective_margins_.footer = 0;
  effective_margins_.left = 0;
  effective_margins_.top = 0;
  effective_margins_.right = 0;
  effective_margins_.bottom = 0;
like image 73
Dave Mackintosh Avatar answered Mar 10 '26 01:03

Dave Mackintosh