Specify hairline thickness in CSS for printing

后端 未结 6 1353
失恋的感觉
失恋的感觉 2021-02-01 23:56

If I have a print CSS styling an element with:

border:1px solid black;

or:

border:0.25pt solid black;

The lin

6条回答
  •  失恋的感觉
    2021-02-02 00:37

    I suggest to use a tool which converts the HTML document to a PDF first. Then you can print the PDF and get consistent results. Wkhtmltopdf is very good for that because it's based on the most standard compliant web rendering engine.

    When using wkhtmltopdf you can set the zoom to a value above 1 to get thinner lines. Set the line width to something like 0.25pt and use the following command.

    wkhtmltopdf -T 0 -B 0 -L 0 -R 0 -s A4 --zoom 10  
    

    Now you get really thin lines. When you specify a higher zoom value the rendering is more precise and looks therefore slightly different.

    To get the best results use the following units: mm, cm and pt instead of px.

提交回复
热议问题