pontedilana / php-weasyprint

PHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint
MIT License
52 stars 11 forks source link

Difference in rendering #13

Open garak opened 1 month ago

garak commented 1 month ago

First of all, thanks for this awesome package. I was looking exactly for a way to replace snappy (and wkhtmltopdf) with something still supported. So, I tried to remove snappy and install this library in a project of mine, and the migration was really smooth.

The problems raised when I tried to render a pdf: the page layout is quite different, with many wrong positions (I guess related to margins, but I'm not sure)

I understand this is not strictly related to this library, but rather to the differences between wkhtmltopdf and wasyprint, however I was wondering if someone experienced the same and could provide a way to ease the migration path. If so, it could be mentioned in the README. Otherwise, this could be mentioned in the list of differences.

endelwar commented 1 month ago

Hi @garak,

Yes, the different engines can sometimes generate quite different outputs. There are some tips on this WeasyPrintBundle issue that show how to adapt your CSS to fix some rendering inconsistencies.

Some other indications can also be found on this other issue.

As you guessed, margins, paddings, and page size are often the main culprits behind these inconsistencies.

Feel free to open a PR to enhance the README!