Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You cant do page numbering in html? Seriously? I haven't had an issue with any of these things rendering html to pdf.


The Paged Media spec on counters and counter-resets paints implementations into a corner. They can't both comply with the spec and implement page count resets on page breaks. This has been a known issue with the spec since 2013[1][2] and been a thorn in implementations since.[3]

1: https://www.w3.org/Style/CSS/Tracker/issues/334

2: https://github.com/w3c/csswg-drafts/issues/4760

3: https://github.com/Kozea/WeasyPrint/issues/93#issuecomment-4...


Here's some PHP code to handle page numbering (page breaks are no problem at all rendering html to pdf) :-

<?php

$pagenum = 1;

$pagenum++;

print("Page: $pagenum");

?>


I’ve had trouble with html -> pdf when it comes to tables. Most of the packages out there don’t have a way to say “if only the first few rows of the table will render before a page-break, then put the page-break before the table”. Or getting a table to not break at row X when that row has a cell that spans more than one row. Or getting table headings to repeat on the next page when a page-break mid-table is unavoidable.

These are all things that good page layout software can deal with easily.

HTML to pdf is also pretty slow and unreliable when you want a table of contents or an index with page numbers. On a fast machine, a 200 page PDF can take several minutes to generate. PrinceXML is the only software I’ve tried that does a good job of it. For very simple documents (no CSS, limited Unicode) HTMLDoc is pretty good and very fast.


I agree with html you have to manage the pagebreak within the code but honestly its not that complicated to insert a pagebreak based on rowcount.


Row count is not the only condition for how much can fit on a page.

Content matters for row height, as does fonts, styling, etc. Footers, too. The number of footnotes (thus the height of the footer) can depend on the page content, too.

Maybe there's an image in there, or some sort of specially styled content that makes the line height larger than normal.

You have to be able to render the row to know the final dimensions, to be able to make a call whether it should go on that page or the next. If you don't, then you end up with one page actually rendering over into a second page.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: