From 912df09249e699a06d5f19e01d0e8bf712d8f08f Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Thu, 8 Apr 2021 15:48:34 +0200 Subject: Add PDF articles article --- .../downloading-articles-for-my-ebook-reader.html | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/blog/downloading-articles-for-my-ebook-reader.html diff --git a/src/blog/downloading-articles-for-my-ebook-reader.html b/src/blog/downloading-articles-for-my-ebook-reader.html new file mode 100644 index 0000000..8e5d463 --- /dev/null +++ b/src/blog/downloading-articles-for-my-ebook-reader.html @@ -0,0 +1,99 @@ +title: Downloading Articles for my Ebook Reader +date: April 08, 2021 14:40 +--- +

+I've recently taken to reading blog posts and other internet articles on my +ereader. And I don't mean using my tablet's browser and wifi connection to load +up websites. Instead, I convert the articles I want to read to PDF and read them +like I would any other ebook (I have a large screen tablet on which reading PDFs +is very comfortable; I would probably be playing around with EPUB conversion if +I had a smaller screen). +

+ +

+The obvious way to get a PDF of a website would be to use my browser's built in +print-to-PDF feature. But this has some minor problems for me: + +

+

+ +

+That second point — about automation and scripting — was +particularly important to me. So the obvious tool for the job was the Swiss-army +knife of document conversions, pandoc. +

+ +

+For a while I was wondering if I would have to write some clever script that +downloads all of the article's HTML and other resources (like images) and then +inputs them to pandoc. Fortunately, it turns out that pandoc +<article url> -o <output file> does exactly what you think it +does. The article ends up converted to PDF, with LaTeX used as an intermediate +step, so everything is in the beautiful LaTeX font. pandoc also +takes care of downloading and including images. +

+ +

Hotkeys

+

+I wrote a short script that calls pandoc and saves the PDF in a +specific directory. With that script available and working, I added hotkeys to +my browser and RSS reader that invoke it. These are the two programs in which I +might find articles to read, and now I can easily generate PDFs from both. +

+ +

+Here's what the newsboat config looks like: + +

+macro p set browser "article2pdf %u" ; open-in-browser ; set browser "elinks %u"
+
+ +And here's the qutebrowser binding: + +
+config.bind(
+        '"P',
+        'spawn article2pdf {url}'
+)
+
+ +(article2pdf being the name of my script) +

+ +

Caveats

+

+This doesn't work perfectly. + +

+

-- cgit v1.2.3