Hi Crabbly! First of all an impressive repo for working with print related projects.
I just have one question though. While working for a recent client, they told me that they have their own letterhead for printing. So I have to give a top and bottom margin in HTML div I am trying to print. Fine with a single page print. But the problem arises when it is multipage. From 2nd page onwards the margin is out of question. I can fix the margin from printing dialog manually.
However, is there a way this library can support this feature somehow magically?
It is not an issue though, more of an enhancement request.
Hi Sudip, javascript cannot control the user browser settings, including the printing margins. Ref #79
About adding a margin to the first page, I think a possible solution would be to add margin to the div you are trying to print, through a CSS media query (@media print).
Unfortunately the library doesn't currently support that. I'm planning on adding it as soon as I have a chance. Ref #157
I was searching the web for this. I found that a CSS property @page can do this for the full
printing. But I am not getting the idea how I can use this for a particular div. You can refer the link below for a stackoverflow question.https://stackoverflow.com/questions/50103387/using-page-property-for-a-particular-div-in-html
Hey Sudip, the library has now a new parameter (css) which allow us to pass a url to a css file that could have CSS media queries to be applied when printing html elements. For example @media print.
http://printjs.crabbly.com/#configuration
You can now play with it to add margins to your pages when printing.
Good luck.
Make sure to update the library first (npm update print-js).
You are a life savior man!! I am going to test this tomorrow first thing! Lots of love and gratitude.