I have defined the Print CSS through media print in my CSS file. In Chrome and Firefox, the same is getting applied. Whereas in Internet Explorer and Edge Browser, I need to manually select the scale to 75% and letter size to 8.5" * 11" and then print. Is there a way through Java (As my backend runs on Play Framework) or JavaScript to define it in the first place? Thanks in advance
Asked
Active
Viewed 995 times
2
-
Possible duplicate of [Can I modify the Windows 7 preview pane so HTML files display just the text in the preview instead of rendering the html?](https://stackoverflow.com/questions/15375298/can-i-modify-the-windows-7-preview-pane-so-html-files-display-just-the-text-in-t) – Paul Sweatte Jun 12 '17 at 18:49
1 Answers
1
Some browsers (e.g. Chrome) do support the ability to specify "hints" via CSS to the browser in terms of printing preferences.
<style>
@media print{
@page{
margin:1in;/* Default margin (for page content) */
/*margin:0in; Sets margin to zero AND hides all the page #/date/URL fluff */
size:landscape;/* Default to Landscape */
}
}
</style>
Sadly this is not an official standard yet and is considered experimental: https://developer.mozilla.org/en-US/docs/Web/CSS/@page/size
I'd certainly love all browsers to pick this up as it would be great to be able to provide sensible printing defaults to user agents.
Current support for Landscape & Margin:
- Chrome
- Vivaldi (based on Chrome)
- Brave (based on Chrome)(although there is currently no print preview)
- Opera (based on Chrome)
Current support for Margin only:
- Firefox
Test Page: https://css-printing-hints.glitch.me/

scunliffe
- 62,582
- 25
- 126
- 161