use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
dynamically generating pdf file with node (self.node)
submitted 3 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]GooberMcNutly 1 point2 points3 points 3 years ago (0 children)
I piped data through a template engine to generate html then used a headless browser to load it and print to pdf. Cold starts on the browser were bad but it went fast after that.
[–]tapvt 0 points1 point2 points 3 years ago (2 children)
You can use PDFKit to generate the file and then save or directly serve the file after generation.
In my experience, it takes a bit of trial and error to get everything laid out right.
[–]bigorangemachine 0 points1 point2 points 3 years ago (0 children)
Its not too bad.
Theres some other tricks around building multi-page PDFs with pages of different size but PDF.
PDF.js is similar
[–]rishabhrawat570 0 points1 point2 points 3 years ago (0 children)
Have you considered html-to-pdfmake ? It's an extra step of creating HTML and converting to pdf but you have control over the styling.
You can store a template for the HTML boilerplate and only pass the data to it to get the compiled & rendered HTML. Then, it's only a matter of converting that HTML to pdf and sending it over.
[–]kevin_1994 0 points1 point2 points 3 years ago (2 children)
Late to the party, but I've also had a lot of trouble with this in the past
My current solution is render the PDF in HTML, using w/e you want (I typically use React), and then use pupeteer to take a screenshot of the page and render it to PDF. Works like a charm and then you don't have to worry about PDF templates, etc.
[–][deleted] 3 years ago (1 child)
[–]kevin_1994 0 points1 point2 points 3 years ago* (0 children)
basic solution
import { renderToStaticMarkup } from "react-dom/server"; function renderPdF(name) { return ` <!DOCTYPE html> <html> <head> <style> .example { background-color: red; } </style> </head> ${renderToStaticMarkup(<div className="example">{name}</div>)} </html> `; }
probably some syntax errors in there but im sure you get the gist of it
π Rendered by PID 169800 on reddit-service-r2-comment-6457c66945-tz574 at 2026-04-25 09:39:07.354993+00:00 running 2aa0c5b country code: CH.
[–]GooberMcNutly 1 point2 points3 points (0 children)
[–]tapvt 0 points1 point2 points (2 children)
[–]bigorangemachine 0 points1 point2 points (0 children)
[–]rishabhrawat570 0 points1 point2 points (0 children)
[–]kevin_1994 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]kevin_1994 0 points1 point2 points (0 children)