multiple prints on the same line in Python

Python 3 Solution The print() function accepts an end parameter which defaults to \n (new line). Setting it to an empty string prevents it from issuing a new line at the end of the line. def install_xxx(): print(“Installing XXX… “, end=””, flush=True) install_xxx() print(“[DONE]”) Python 2 Solution Putting a comma on the end of the … Read more

CSS to set A4 paper size

I looked into this a bit more and the actual problem seems to be with assigning initial to page width under the print media rule. It seems like in Chrome width: initial on the .page element results in scaling of the page content if no specific length value is defined for width on any of … Read more

Landscape printing from HTML

In your CSS you can set the @page property as shown below. @media print{@page {size: landscape}} The @page is part of CSS 2.1 specification however this size is not as highlighted by the answer to the question Is @Page { size:landscape} obsolete?: CSS 2.1 no longer specifies the size attribute. The current working draft for … Read more

Background color not showing in print preview

The Chrome CSS property -webkit-print-color-adjust: exact; works appropriately. However, making sure you have the correct CSS for printing can often be tricky. Several things can be done to avoid the difficulties you are having. First, separate all your print CSS from your screen CSS. This is done via the @media print and @media screen. Often … Read more

How to deal with page breaks when printing a large HTML table

<!DOCTYPE HTML> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>Test</title> <style type=”text/css”> table { page-break-inside:auto } tr { page-break-inside:avoid; page-break-after:auto } thead { display:table-header-group } tfoot { display:table-footer-group } </style> </head> <body> <table> <thead> <tr><th>heading</th></tr> </thead> <tfoot> <tr><td>notes</td></tr> </tfoot> <tbody> <tr> <td>x</td> </tr> <tr> <td>x</td> </tr> <!– 500 more rows –> <tr> <td>x</td> </tr> </tbody> </table> … Read more