10

There is a print setting (Scale) in Chrome that I would like to emulate.

enter image description here

In IE11, I have added in the css and that seems to fix it but not in Chrome.

@page {
  size: A4 portrait;
  margin: 1mm 1mm 0 5mm;
}

In Chrome, I have to manually change the scale to 50 to fix it. I have tried in css

zoom: 50%
transform: scale(0.5);

UPDATE Now I know why it is working in IE11. Nothing to do with setting the A4 size. Looks like IE has a 'Shrink to Fit' settings that's turned on by default. I don't think there is a way to do in CSS.

ove
  • 3,092
  • 6
  • 34
  • 51

3 Answers3

2

Finally found the answer.

It is because of the bootstrap css.

I implemented the fix below and it seems to work for now.

https://github.com/twbs/bootstrap/issues/12078

ove
  • 3,092
  • 6
  • 34
  • 51
0

You cannot provide zoom in @page. However you can set zoom to parent container inside @media print. You can do something like this

@media print: {
    .container: {
      zoom: 50%;
    }
}

Here container class is applied to parent, so when you print it entire screen will be scaled to 50%.

As per documentation @page only support size, marks and bleed. More details available over here https://developer.mozilla.org/en-US/docs/Web/CSS/@page.

For more details about using print css you can read beautiful blog by Racheal Andrew. https://www.smashingmagazine.com/2015/01/designing-for-print-with-css/

You can check pen here https://codepen.io/sandipnirmal/pen/ajWWgp.

Following are screenshots:

Chrome Scaling:

Chrome print view scaled to 50

Media Print with zoom: 50%

Zoom level set to 50% for media query

Sandip Nirmal
  • 2,283
  • 21
  • 24
  • Does not work. When you zoom the control zoom out as it is, different to what the scale property is doing in chrome. – ove Jul 23 '18 at 10:59
  • @ove I updated the answer to use ``scale`` instead of zoom. You can check the codepen example. I think it should help you. – Sandip Nirmal Jul 24 '18 at 04:05
  • Have you checked the codepen? Can you add your example code/page structure? – Sandip Nirmal Jul 24 '18 at 05:46
  • Yes, I changed the scale value in your pen and nothing happens on Chrome – ove Jul 24 '18 at 06:25
  • @ove can you use ``zoom: 50%`` instead of ``transform: scale(0.5)`` and remove ``transform-origin``. I made changes to the original answer. Also modified pen. It is working perfectly for me. You can give it a try. – Sandip Nirmal Jul 25 '18 at 04:06
  • @ove Actually, I was using ``zoom`` earlier then switched to ``scale`` not sure why, but ``zoom`` seems to work just fine. – Sandip Nirmal Jul 25 '18 at 04:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/176696/discussion-between-sandip-nirmal-and-ove). – Sandip Nirmal Jul 25 '18 at 08:17
0

Those are User settings you are trying to manipulate and you cannot alter the Scale. Try this out:

@media print {
body {transform: scale(.5);}
table {page-break-inside: avoid;}

}

Torjescu Sergiu
  • 1,483
  • 10
  • 24