How to set Safari print margins via CSS to print borderless

css, printing, webkit

Solution

There is 3 things to take in consideration:

The margin of the page's rule, unfortunately

@page {
margin: 0cm !important;
}

Has no effect on Safari 6, where it does in Chrome 23. As I know, as long as Safari is not supporting this, there is no solution (it seems to be fixed to around 10mm).

The page setting as seen here you might have to define a custom "Paper Size" in the "Print…" menu panel without any margin (you did it already btw).

Obviously to take care of the other inner content html, body… not to have any margin.

Problem

I want to print a webpage to PDF without any margins in Safari. Page size is set to 'A4 borderless' in the print dialogue. Whatever I seem to do, Safari on OSX is adding an extra margin around my HTML. Check 'print backgrounds' to see what I mean. Clearly the @page-rule has no effect for Safari, but are there any other ways? http://jsfiddle.net/willemvb/psFHC/ ``` @page { size: 21cm 29.7cm; /*A4*/ margin: 0; /*webkit says no*/ } html{ margin: 0; padding: 0; width: 100%; } body { margin: 0; padding: 0; font-family: sans-serif; width: 100%; background: #eee; } ``` ​

Original source