HTML+CSS generated .pdf file has different layout on different computers?

496 Views Asked by At

I managed to generate a .pdf file using HTML and CSS. The size of the page is predefined in inches (A4 format). It works great on my computer, but when I run the program on a different computer, the generated file looks different, the pages remain A4, but the layout changes, although both computers have the same resolution and dpi.

1

There are 1 best solutions below

0
On

Using CSS maintain design for both.

@media print - for printers

@media screen - for for computer screens, tablets, smart-phones etc.

@media print{
   h1{
      color:red;
   }
}


@media screen{
   h1{
      color:blue;
   }
}
<h1>Hello</h1>

Click on "Result" in Snippet screen and press "CTRL + P".