new project, a pdf reader (FolioPDF)
/blog/making-a-pdf-reader/hello there,
so i’ve been working on a new project, it’s a pdf reader called FolioPDF, and eventually i also want to make it a pdf editor as well. the idea was to make something lightweight and easy to use, while also having a nice looking interface, so i decided to build it around Mozilla’s PDF.js, which is what Firefox uses for its pdf viewer.
i wasn’t gonna start by building the entire app straight away, because i wasn’t even sure how i wanted it to look. so i started with some mockups first, just to figure out the interface and where everything should go, and after a few changes it started looking quite like material you, which i liked.
then i wanted to add more things, text tools, a highlighter, tabs, settings for the colours, open and save options, etc. mostly icons for the tools, because i don’t want half the window to be occupied by buttons when i’m trying to read something. also the tabs and other bars needed to be a little slim, so there’s more space for the actual pages.
however, all of that was still just the design. i decided to start with only the reader first and slowly add things later, because adding everything at once would’ve made it much harder to figure out what broke and why. so for now it’s mostly just opening pdfs, selecting text, scrolling through the pages and changing the zoom. usual reader stuff.
for the actual app i went with Tauri, TypeScript, Vite and plain CSS, with PDF.js handling the pdf part. Tauri handles the desktop window and things like the native file picker, and the interface runs inside the system webview, which is WebView2 on Windows and WebKitGTK on Linux.
so basically i can use PDF.js for displaying the document without having to write a pdf renderer myself, and Tauri lets me make it a desktop app while keeping the app package small. i’m also just using plain TypeScript for the interface, there’s no separate frontend framework involved here.
oh btw, while setting up the Windows build i had to install Microsoft’s C++ Build Tools and a Windows SDK, and when i ran the installer it opened the Visual Studio Installer. i was like, huh? i’m trying to make a lightweight pdf reader and now i have to install visual studio?
turns out it’s the same installer for the build tools too, so i went with the minimal compiler and SDK components instead of installing the whole development workload. i really didn’t want to obliterate my disk just to compile this thing lol.
and before anyone asks, no, you won’t need to install all these build tools to use the app. they’re only required if you’re compiling it from source. the Windows app itself needs WebView2, which the setup installer checks for.
anyways, after getting the reader working and testing it on both Windows and Linux through WSLg, i made the first release, FolioPDF 1.0. there’s a Windows installer and a portable zip, and for Linux i also made a debian package, an AppImage and a traditional .tar.gz archive.
the linux packages were tested on Ubuntu under WSLg, so i can’t say they will work on every distro. also no macOS support yet, because Windows and WSL are what i can actually test on right now.
after that i started working on tabs, which is what i just finished. each document opens in its own tab and keeps the page, zoom and reading position, so if you open another pdf and go back to the previous one, you don’t have to find your page again. there’s also Ctrl+Tab and Ctrl+Shift+Tab to switch between them, and Ctrl+W to close the current one.
the tabs share one PDF.js viewer and one worker, instead of having a separate viewer for every document. the pdfs stay loaded when switching, but the old page views and canvases get removed, and closing a tab releases its document too. i wanted to keep this part fairly simple as well, especially since editing will need more work later.
testing was done in the browser and in the actual desktop apps on both Windows and WSL, because the native file picker and webview also need to work, not just the browser version. all 13 browser tests passed on both, and the desktop checks included opening different pdfs, switching back to check the saved position, and closing tabs while making sure the remaining pdf still works.
do note that the tabs are only in the local development version right now, they aren’t included in the 1.0 release yet. the repo is also still private for now.
i still want to add text, highlighting and the other editing tools that were in the mockup, but i haven’t started that part yet, and saving edited pdfs isn’t supported either. for now i just wanted to get the reader and tabs working properly before moving on to those things, so that’s what i’ve been doing.
anyways, i will keep working on it slowly and update you guys when there’s more to show. for now that’s pretty much it :)