Currently I think the best solution is a headless browser, I use chromium+puppet, plus polyfills like paged.js. Now I can finally have most of the CSS paged media features, including page references.
Then there is the topic of word hyphenation. Chrome technically supports it through CSS, but in practice that is harder to achieve, afaik due to problems with distributing the dictionaries. There are again polyfills. I also think there should be a way to train a neural net on existing hyphenations to hyphenate virtually anything else in a sensible fashion, including fantasy words.
Without hyphenation, text justification doesn't work properly. It's also a good way to save space in tabular layouts, even if just for display on-screen.