Reputation: 21
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
Upvotes: 2
Views: 1241
Reputation: 63588
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:
Current support for Margin only:
Test Page: https://css-printing-hints.glitch.me/
Upvotes: 1