|
|
|
|
|
by andreareina
2947 days ago
|
|
A warning from my own experience: do not use web technologies for any printing (including rendering to pdf) where positioning is critical (e.g. for filling out pre-printed forms). Fiddling with `@media print {…}` and `position: absolute` will work… until there's some minor change in the rendering engine that will throw all that careful work into disarray and leave you asking questions like, "why is this right-aligned bit of text in an 8.5-inch wide container being printed down the middle of my page?" (the preview looked great btw). Oh, and the vertical scale was only slightly short, so I couldn't just scale the page. The right answer in this case was a package that actually spoke pdf and would flow text into a fixed-size box at a fixed location. Oh, and once you've got the file, don't let the browser print it either -- somehow both Firefox and Chrome wouldn't render it to the printer correctly, and of course they would mess up in different ways. Browsers are good at laying things out on the screen. On paper, not so much. |
|
I've looked into JS libraries that will directly generate PDFs you can print but each library seems to come with a lot of caveats.