Live data from Hacker News

Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

news.ycombinator.com

151–160 of 170 posts

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#151

Earlier quoted context omitted.

My exercise bike can play Doom on its display in theory. Theory doesn't matter here, tooling and standards do. And PDF doesn't just have the tooling for highlighting and annotations, it has the standards for them so that tools support them in an interoperable way. A highlight made with one tool can be removed with another, without altering the underlying content.

I would love an exercise bike that runs doom. Maybe link my movement speed in-game to how fast I pedal, with a joystick on one of the handlebars to move and a couple buttons on the other one to shoot and reload. So far every exercise bike game is just bike race, which I'll admit is a close fit for the existing hardware and probably the first idea I'd have too but it gets boring after a while.

Had the same idea - not with doom - but with a Quest 3D and watching videos of me riding in the summer. First make a film using an 3D camera (something like a Insta360) and then view that on the Quest in winter while riding exercise bike.

Video speed would sync to the exercise bike speed, giving a feeling of reality.

The core problem is that sweating inside a Quest isn't a good idea ...

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#152
post #7

Just print to PDF in a browser, or automate that using a browser automation tool. For a non-browser-based open source solution, WeasyPrint. https://weasyprint.org/ For a proprietary solution, try Prince XML: https://www.princexml.com/

I'll join the choir. We use weasyprint for ebooks and invoices and it's a joy to use. Massively new support for features over the last few years (partially thanks to some monetary sponsorships), it started pretty bare bones, and is now close to commercial solutions.

The maintainers are also very responsive, and helpful.

Amazing project

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#153
post #129
post #79

Earlier quoted context omitted.

Most website do not have a print CSS, so it doesn’t print that nicely in PDF. But, I upvote weasyprint for that instead.

> Most website do not have a print CSS, so it doesn’t print that nicely in PDF. Can't they just render the screen content in a pdf ? Seems easy for other programs to do this.

Viewport size and deciding where to paginate makes a naive approach to this surprisingly difficult. That being said, if you can control the css / html, you can often solve these problems with a short media query and some hints at where to break pages (e.g. https://developer.mozilla.org/en-US/docs/Web/CSS/break-after).

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#154
post #138

Earlier quoted context omitted.

>Sometimes you want one, sometimes, the other. This is the part that the top commenter missed. Instead they decided that one format is "nice" and the other, by implication, isn't. I find PDFs a lot easier to keep organized en masse, I like that I can use them on any of my devices and it's easy for me to use them when I'm doing in-depth reading such as an ebook. Doubly so because my ereader also does text to speech an…

None of that sounds related to the format? - A text to speech engine should work better with the original html structure where it sees bold tags, headings, and full sentences ra- ther than broken-off ones - Keeping PDFs organised, how would that differ from keeping any other filetype organised? I don't understand what difference you, "by implication", attribute to a file ending in .html or .pdf for being able to hand…

>and full sentences ra- > >ther than broken-off ones

This and trying to read the header/footer are the most annoying parts of pdf to audio apps. At least some apps will let you set a margin outside of which text is ignored, so every page doesn't start with the book title, author's name and chapter title and end with the page number.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#155

Earlier quoted context omitted.

I would love an exercise bike that runs doom. Maybe link my movement speed in-game to how fast I pedal, with a joystick on one of the handlebars to move and a couple buttons on the other one to shoot and reload. So far every exercise bike game is just bike race, which I'll admit is a close fit for the existing hardware and probably the first idea I'd have too but it gets boring after a while.

Had the same idea - not with doom - but with a Quest 3D and watching videos of me riding in the summer. First make a film using an 3D camera (something like a Insta360) and then view that on the Quest in winter while riding exercise bike. Video speed would sync to the exercise bike speed, giving a feeling of reality. The core problem is that sweating inside a Quest isn't a good idea ...

I did thrill of the fight a lot back during the pandemic. sweating in a quest isn't ideal, but it's not unmanageable for brief periods of time (15-30 minutes). The only real problem is that the lenses can get sweaty or foggy and all of a sudden I go from punching faces and dodging fists to punching at blurs and failing to dodge other blurs.

Maybe instead of a quest you just display video to a screen? When I was using a hotel fitness center they had a peloton and that seems to be something you can do with those. It was a couple years back and I recall the video being loosely if at all tied to the speed you pedal at, but it was more fun than just looking at a wall while I pretend to go somewhere.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#157
post #20

Earlier quoted context omitted.

There are multiple ways to "depend", so if pandoc executes some external tool all of the work then might as well use that external tool directly. You will get more control over how the conversion happens, know for what search for when in trouble etc.

My understanding and experience is that Latex has a significant learning curve and Pandoc provides a more gentle front end. Of course Latex gives you fine control to hand tune the engine…but that doesn’t seem like what the OP is looking for.

Sure, I don't mean that anyone would look at the Latex in between. I'm just saying that if tool x directly calls tool y to do the job then might as well use tool y directly.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#158
post #144

Earlier quoted context omitted.

That's different. Those are a data structure defining annotations that are meant to be stored externally. They're not part of an HTML file like PDF annotations are. They're meant more for live collaborative commenting within a shared online space, not for making private portable annotations like PDF does. And it's not a Chrome thing. I don't think any browsers support it, do they? It's not really clear there's a need…

So is there a need for it or isn't there? > That's different. Those are a data structure defining annotations that are meant to be stored externally. The protocol is a separate standard. The format is JSON-LD. Putting JSON-LD into HTML isn't a question mark. (There's info at W3C.org about how to do that, too. Not that it's necessary. You can guess what it says.)

Sorry, yes you're right the annotations can be embedded too.

But these aren't meant for direct user annotations in a general way.

The web standard doesn't define any standardized mechanism for one user to add highlights and comments, and another user to see them and edit them further.

The annotations are tools that software can use for its own purposes. They're not a user-facing feature like they are in PDF.

They're both called "annotations" but they're completely different. Completely different technologies for completely different use cases.

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#159
post #13

chrome --headless --disable-gpu --print-to-pdf https://example.com

same: google-chrome --headless --disable-gpu --no-pdf-header-footer --hide-scrollbars --print-to-pdf-margins="0,0,0,0" --print-to-pdf --window-size=1280,720 https://example.com ended up using headless chrome specifically to make sure javascript things rendered properly

Used this, sigh of relief, thank you

Re: Ask HN: What is nowadays (opensource) way of converting HTML to PDF?

#160
post #114
post #110

Earlier quoted context omitted.

> Unfortunately, that server and software stack is still around and still in production. that means you did a good job.

2010-era Firefox is probably plagued by security holes.

My biggest concern would be the Perl libraries I used to sanitise the input. I checked and none of them have any CVEs, though.
Post reply on HN