{"id":10824,"date":"2025-06-06T03:00:00","date_gmt":"2025-06-06T07:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=10824"},"modified":"2025-05-31T16:31:21","modified_gmt":"2025-05-31T20:31:21","slug":"viewing-pdf-documents-in-console-mode","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=10824","title":{"rendered":"Viewing PDF documents in console mode"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"10824\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">1    <\/span>\r\n<\/div><\/div>\n<p>I have a Raspberry Pi 3 that\u2019s sat unused for the last few years. I used to run the Raspberry Pi as a personal \u201chome server,\u201d such as a printer server to share my old \u201coffline\u201d laser printer on my home WiFi. But ever since I bought a new printer a few years ago, I haven\u2019t had a good use for the Raspberry Pi. Until now.<\/p>\n\n\n\n<p>I started a <a href=\"https:\/\/www.both.org\/?p=10813\">retrocomputing experiment<\/a> to see if I can still be effective as a technical writer, but doing it without a graphical user interface. I\u2019m doing everything at the command line. To do that, I installed Fedora Minimal on the Raspberri Pi\u2014this gives me only the packages that are necessary to boot the Raspberry Pi. Fedora Minimal doesn\u2019t provide a full desktop environment or even many of the command line tools that I\u2019m used to. If you want to use a command that\u2019s not installed with Fedora Minimal, you have to install the package.<\/p>\n\n\n\n<p>While this might sound restrictive to some folks, I like it because it lets me explore the <em>minimum<\/em> set of tools that I need to be effective as a writer, without loading a graphical user interface.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"most-things-are-easy\">Most things are easy<\/h2>\n\n\n\n<p>As someone who grew up with computers in the late 1970s and early 1980s, and used DOS from the 1980s into the 1990s, and run Linux since 1993 before graphical desktops were common, I am already comfortable using the command line. I\u2019ll gladly use <strong>ls<\/strong> and <strong>cd<\/strong> to navigate my filesystem, and <strong>less<\/strong> and <strong>vi<\/strong> to view and edit content.<\/p>\n\n\n\n<p>I learned how to write text documents with <strong>nroff<\/strong> when I was an undergraduate student using our campus computer lab. At the same time, I quickly learned how to use <strong>groff<\/strong> and LaTeX on my Linux desktop at home to provide more interesting formatting for other documents, such as equations and charts in my lab reports for physics classes.<\/p>\n\n\n\n<p>These days, I write most of my first drafts in Markdown, then convert to something else to make final edits or to transmit the file to someone else. Writing in Markdown with a plain text editor like <strong>vim<\/strong> makes it easy for me to focus on what I\u2019m writing and not how it will appear on the page.<\/p>\n\n\n\n<p>So far, I didn\u2019t need to change how I used Linux at the command line to do my work. I could still use <strong>vim<\/strong> to write in Markdown, and <strong>pandoc<\/strong> let me convert from Markdown to something else. The only change was that I could only work on one thing at a time\u2014there\u2019s no switching between \u201cwindows\u201d when you\u2019re working entirely at the command line.<\/p>\n\n\n\n<p>I also used the experiment as an excuse to <a href=\"https:\/\/www.both.org\/?p=9604\">format documents<\/a> using <strong>groff<\/strong> with the <code>ms<\/code> macros. But that\u2019s where I ran into trouble. While <strong>groff<\/strong> is a superset of the old <strong>nroff<\/strong> and <strong>troff<\/strong> formatters, and I could run <strong>nroff<\/strong> to format documents as text to view on my terminal, viewing a PDF generated from <strong>groff<\/strong> seemed like a major obstacle for doing my work at the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-the-framebuffer\">Using the framebuffer<\/h2>\n\n\n\n<p>Fortunately, that wasn\u2019t the end of my experiment. When booting Linux on real hardware connected to a display, you\u2019re actually at the <em>console<\/em>, not a <em>terminal<\/em>. The difference is that a terminal (or terminal emulator, if you\u2019re doing it from a window on your graphical desktop) only provides basic access to the display. You\u2019re going through an <em>emulated<\/em> layer.<\/p>\n\n\n\n<p>However, the console is different. With the console, you can directly leverage the display hardware on the system. This is usually done through the <em>frame buffer<\/em>, which is the same way that your Linux desktop puts the system into graphics mode. Except when you\u2019re running entirely in console mode, you can use other tools that take advantage of the frame buffer.<\/p>\n\n\n\n<p>One program is <strong>fbi<\/strong>, which is a <strong>f<\/strong>rame <strong>b<\/strong>uffer <strong>i<\/strong>mage viewer, available at <a href=\"https:\/\/github.com\/kraxel\/fbida\">kraxel\u2019s GitHub<\/a>. This is actually a collection of programs that can use the frame buffer; displaying images is just one feature.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>fbida.x86_64<\/code> views images<\/li>\n\n\n\n<li><code>fbida-fbgs.x86_64<\/code> displays PostScript files using GhostScript<\/li>\n\n\n\n<li><code>fbida-fbpdf.x86_64<\/code> views PDF files<\/li>\n\n\n\n<li><code>fbida-ida.x86_64<\/code> uses Motif (not useful for me in console mode)<\/li>\n<\/ul>\n\n\n\n<p>The feature I was most interested in was <strong>fbpdf<\/strong> to display PDF files. You can install <strong>fbi<\/strong> using this command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo dnf install fbida fbida-fbgs fbida-fbpdf<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"viewing-pdf-documents-in-console-mode\">Viewing PDF documents in console mode<\/h2>\n\n\n\n<p>With <strong>fbpdf<\/strong>, I am able to view PDF documents using the frame buffer, without having to start a graphical desktop environment. The only issue I had was that <strong>fbpdf<\/strong> didn\u2019t know how to access the frame buffer on its own. To view output, I had to tell <strong>fbpdf<\/strong> which display device to use. On the Raspberry Pi, this is the <code>\/dev\/dri\/card1<\/code> device.<\/p>\n\n\n\n<p>For example, I wrote a sample report using the <code>ms<\/code> macros, just to demonstrate how I might prepare a document for printing using <strong>groff<\/strong>. To process this and generate a PDF file, I can use the <strong>pdfroff<\/strong> wrapper to the <strong>groff<\/strong> command, which otherwise has the same command line options as <strong>troff<\/strong> or <strong>groff<\/strong>, but saving to a PDF output file by default:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ pdfroff -ms report.ms &gt; report.pdf<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"http:\/\/www.both.org\/wp-content\/uploads\/2025\/05\/pi-pdfroff.png\" alt=\"running pdfroff on the command line\" class=\"wp-image-10818\"\/><figcaption class=\"wp-element-caption\">Preparing a PDF with pdfroff<\/figcaption><\/figure>\n\n\n\n<p>To view the generated PDF document, I can use <strong>fbpdf<\/strong> from the command line, specifying the frame buffer device:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ fbpdf -d \/dev\/dri\/card1 report.pdf<\/code><\/pre>\n\n\n\n<p>You can navigate the PDF document using the keyboard. <strong>fbpdf<\/strong> supports several keyboard shortcuts to control the display, but most of the time I just used <code>PgUp<\/code> and <code>PgDn<\/code> to go \u201cup\u201d and \u201cdown\u201d through the pages, and <code>Esc<\/code> to quit.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"http:\/\/www.both.org\/wp-content\/uploads\/2025\/05\/pi-fbpdf.png\" alt=\"viewing a PDF using fbpdf\" class=\"wp-image-10816\"\/><figcaption class=\"wp-element-caption\">Viewing page 1 of a PDF at the console<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Working at the console<\/h2>\n\n\n\n<p>This retrocomputing experiment is a fun step back in time. But it&#8217;s also a reminder that <em>yes, you really can write modern content at the console<\/em>, you just need to use different tools to get there. Instead of a graphical desktop and point-and-click editor, you need to use a text-mode editor like <strong>vi<\/strong>. If you&#8217;re like me and you write in a markup system like Markdown or <strong>groff<\/strong>, you can still create professional looking documents and save them as PDF; you just need a new tool to preview them. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 I have a Raspberry Pi 3 that&rsquo;s sat unused for the last few years. I used to<\/p>\n","protected":false},"author":33,"featured_media":2818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[100,69,5],"tags":[104,147,91],"class_list":["post-10824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line","category-fun","category-linux","tag-command-line","tag-fun","tag-linux"],"modified_by":"Jim Hall","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10824"}],"version-history":[{"count":4,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10824\/revisions"}],"predecessor-version":[{"id":10844,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10824\/revisions\/10844"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/2818"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}