Skip to content
maussoftPublic

About

PDF reader for Windows with tabs, annotations, form filling and printing, written in Go

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

pdf4win

A PDF reader for Windows that starts fast, has tabs, annotations, form filling and printing, and has no account, no cloud and no AI. It also reads e-books, office documents, comic books and pictures. Written in Go with Windigo, without CGo.

It does what SumatraPDF 3.6 does with PDF files, plus the things people open Adobe Reader for: filling in forms, stamps and signatures, a comments list, booklet printing, a folder search and read aloud. It looks like the other 4win apps: a menu row, one toolbar with the Fluent icons, tabs, a side bar and a status bar, in the light or dark colours of Windows.

pdf4win screenshot

Features

  • Tabs, more windows, reopening a closed tab (Ctrl+Shift+T) and the files of the last time opened again. A file dropped on the window opens in a tab.
  • A home page with the files that were read most, with pinning.
  • Views: single page, facing and book view, continuous or page by page, right to left, rotate, fit page, fit width, any zoom from 10% to 6400%, zoom with Ctrl and the wheel around the pointer, zoom to an area.
  • Fullscreen (F11) and presentation (F5).
  • A side bar with the pages as thumbnails, the bookmarks, the comments and the layers of the document. Layers can be shown and hidden.
  • Adding, moving, rotating and removing pages: right click a page in the side bar to put in the pages of another PDF file, a picture or a blank page, or to move, rotate or delete the page, or save it as a file of its own. Ctrl+click and Shift+click select more pages, to do that with all of them or to reverse their order. PDF files and pictures dropped between the pages are put in there. Interleave with file puts scanned backs between the fronts. Undo takes it back. Rotating a page this way, or with a right click on the page itself, is saved in the file. Rotate the view, in the View menu, turns all pages and leaves the file as it is.
  • A new PDF file made of pictures (File, New PDF from pictures), with a page for each, in the order of their names. The page has the paper size of Windows (A4 or Letter), or in a document that of the page before it, and a margin of 10 mm. A scan with the shape of the paper covers the page. What the camera wrote in a photo, such as the place where it was taken, is left out.
  • A smaller copy of a PDF file (File, Compress), for the screen, for print or as small as possible. Every page of the copy is compared with the original, and what does not look the same is left as it was. Pictures in black and white, in CMYK, with a palette or with transparent parts are not touched.
  • Links inside the document and to the web, back and forward, go to a page by its number or by its label ("iv", "A-1"), favourite pages.
  • Select text with the mouse, copy it, select all. Double click selects a word.
  • Find as you type with all matches marked, match case and whole words, and find in every document of a folder (Ctrl+Shift+F).
  • Annotations in PDF files: highlight, underline, strike out, squiggly line, sticky note, text, freehand drawing, rectangle, ellipse, line, stamps and a picture of your signature. They can be moved, edited and deleted, hidden and shown, in a colour of your choice, with undo and redo of every step.
  • Form filling: text fields, check boxes, radio buttons, lists and drop-down lists. Tab goes to the next field.
  • Save and Save as. A save adds the changes to the end of the file and leaves what was there as it was. Only when pages were deleted, the file is written again as a whole, without the content of those pages.
  • Printing with a page range, fit, shrink or actual size, 2, 4, 6, 9 or 16 pages on a sheet and booklets.
  • A command palette (Ctrl+K): type to find a command, @ for a tab, # for a file that was read before.
  • Read aloud (Ctrl+Shift+U) with the voice of Windows.
  • A measuring tool, inverted colours, scrolling by itself.
  • Document properties, the list of digital signatures in a file (shown, not checked), password protected files.
  • For LaTeX: the file is read again when it changes, and with a .synctex file next to the PDF, -forward-search shows the place of a source line and a double click on a word starts your editor at the line it came from.
  • One running copy: a file opened from Explorer becomes a tab in the window that is there.
  • Follows the light and dark app mode of Windows, or the one you pick.
  • Checks for a newer release on request (Help, Check for updates) and installs it, or opens the download page in a portable copy. Nothing is checked automatically.

Formats

Format Open Annotate and save
PDF (.pdf), also damaged and encrypted files yes yes
E-books (.epub, .mobi, .azw3, .fb2, .chm) yes no
Office documents (.docx, .pptx, .xlsx) yes no
Web pages, Markdown and text (.html, .md, .txt) yes no
Comic books (.cbz, .cbt) yes no
Pictures (.png, .jpg, .gif, .bmp, .tif, .webp, .jp2) yes no
Drawings (.svg) yes no
  • E-books, office documents, web pages and text have no pages of their own: they are laid out on pages of A5, the size of a paperback, and View, Bigger text and Smaller text lay them out again.
  • A comic book is a ZIP or TAR archive of pictures, shown in the order of their names ("page2" before "page10"). RAR and 7z archives (.cbr, .cb7) are not read.
  • A photo is turned as the camera asks (EXIF orientation). Of a GIF that moves and of a TIFF with more pages the first picture is shown.
  • JPEG files are read when they are baseline or progressive, in grey, colour or CMYK. Lossless, arithmetic-coded and 12-bit JPEG, JPEG XL, JPEG XR, HEIC and AVIF are not read.
  • XPS, DjVu and PostScript are not read.

Annotations and forms

An annotation or a form value is first drawn over the page by pdf4win itself. It goes into the file when you save, and until then every step can be undone. Two libraries are at work (see "Libraries" below), and a few things follow from what the one that writes can do:

  • Text on a page is in bold Helvetica and in Western European letters only.
  • On a page that the file turns by a quarter, underline, strike out and squiggly line are saved as drawn lines, and text and the named stamps are refused.
  • A sticky note is saved without a picture of its own; pdf4win and other readers draw their own icon for it.
  • Moving an annotation that another program made redraws it in the style of the library.
  • Signatures are listed with the signer, the reason and the time that the file gives. They are not checked against a certificate, and pdf4win does not sign.

Keyboard

Key Action
Ctrl+O, Ctrl+W, Ctrl+Shift+T Open, close the tab, reopen it
Ctrl+S, Ctrl+Shift+S Save, save as
Ctrl+P, Ctrl+D Print, properties
Ctrl+N, Ctrl+Q New window, exit
Ctrl+Z, Ctrl+Y Undo, redo
Ctrl+C, Ctrl+A Copy, select all
Ctrl+F or /, F3, Shift+F3 Find, find next, find previous
Ctrl+Shift+F Find in a folder
N, P or Ctrl+Down, Ctrl+Up Next page, previous page
Home, End First page, last page
Ctrl+G or G Go to a page
Alt+Left, Alt+Right Back, forward
Space, Shift+Space, PgDn, PgUp Scroll a screen
Arrows or H, J, K, L Scroll
Ctrl+Tab, Ctrl+Shift+Tab Next tab, previous tab
Ctrl+Plus, Ctrl+Minus Zoom in, zoom out
Ctrl+0, Ctrl+1, Ctrl+2, Ctrl+M Fit page, actual size, fit width, custom zoom
Ctrl+6, Ctrl+7, Ctrl+8 Single page, facing, book view
Ctrl+Shift+Plus, Ctrl+Shift+Minus Rotate the view right, left
F5, F11 Presentation, fullscreen
F8, F12 Toolbar, side bar
Ctrl+I Invert colours
Ctrl+B, Ctrl+Shift+B Add this page to the favourites, remove it
Ctrl+K Command palette
Ctrl+Shift+U Read aloud
R Read the file again
Delete Delete the selected annotation
Esc Leave a tool, a mode or the find box
F1 The list of keys
Alt+F, Alt+E, Alt+V, Alt+G, Alt+Z, Alt+T, Alt+H, F10 Open a menu

Other keys can be given to a command in the settings file, by the name the command palette shows: "shortcuts": {"zoom.in": "Ctrl+I"}.

Command line

pdf4win [options] [file ...]
Option What it does
-page 12 Opens at a page
-named-dest name Opens at a named place in the PDF
-zoom 150, -zoom "fit page", -zoom "fit width" Sets the zoom
-view "single page", "facing", "book view", with continuous in front Sets the view
-search text Finds the text after opening
-forward-search file.tex 120 Shows the place of a line of a LaTeX source
-inverse-search "editor %f:%l" Sets the command that a double click starts
-fullscreen, -presentation Starts in that mode
-print-to-default Prints on the default printer and leaves
-new-window Does not use the window that is there
-exec zoom.in Runs a command by its name
--demo Opens a sample document made on the spot

Install

Download pdf4win-<version>-amd64.msi from the releases and run it. It installs pdf4win.exe in %LOCALAPPDATA%\Programs\pdf4win and adds a "pdf4win" shortcut to the Start menu. It installs for the current user only, so it does not need admin rights. Newer versions replace older ones.

After the install pdf4win is in the "Open with" list of Explorer for PDF files, e-books, office documents, comic books and pictures, and pdf4win works in the Run box. It does not take over any file type: choose "Open with", "Choose another app" and "Always" if you want that.

To use it without installing, download pdf4win-<version>-amd64.exe instead and run it from anywhere. It is the same program the installer installs. The settings still go to %APPDATA%\pdf4win, it is not in the "Open with" list, and Check for updates opens the download page instead of installing. For Windows on ARM there is pdf4win-<version>-arm64.exe, a native build that is only available as a portable exe; the installer works there too, but runs the amd64 build emulated.

Each release has a SHA256SUMS file. To check a download, compare its hash with the one listed there, for example in PowerShell:

Get-FileHash pdf4win-<version>-amd64.exe

It runs on 64-bit Windows 10 and 11.

Code signing

release.sh signs the installer and the exes with a Certum code signing certificate issued to Maussoft B.V. To check, right-click the file in Explorer, choose Properties and open the "Digital Signatures" tab. SmartScreen may still warn about a new release until enough people have downloaded it ("More info", "Run anyway"). Do not run a file that is not signed by Maussoft B.V. The source and the build script are in this repository, so you can also build the exe yourself.

Data

Settings (window, side bar, view, theme, print options, annotation colours, your own shortcuts, the files that were read with the page you were on, and the favourites) are in %APPDATA%\pdf4win\settings.json. Tools, Open the settings file shows it. The picture of your signature stays where you picked it; the settings only hold its place.

Nothing is sent anywhere. The only network access is the update check that you start yourself. A link to the web is opened in your browser when you click it, after the status bar has shown where it goes. JavaScript in a PDF is never run.

Libraries

pdf4win is MIT licensed and only uses libraries under the MIT, BSD and Apache-2.0 licenses, all in pure Go. There is no MuPDF, PDFium or Poppler in it. Each library is behind one package, so that it can be swapped:

  • folio (Apache-2.0) reads and draws PDF files, e-books, office documents and drawings. Only internal/folio imports it.
  • Aspose.PDF FOSS for Go (MIT) writes annotations and form values into PDF files. Only internal/aspose imports it. Its AI package is not used.
  • The decoders of Go, golang.org/x/image (BSD-3-Clause) and go-images/jpeg2000 (Apache-2.0) read pictures, in internal/pictures.

go run ./tools/licenses checks the license of every module that is compiled in and fails on any other license. It also writes internal/notices/THIRD-PARTY-NOTICES.txt, with the license texts and notice files, which Help, Third-party notices shows and the installer puts next to the exe. The module of Aspose.PDF FOSS embeds substitute fonts under the SIL Open Font License, which the notices list.

The choice of folio comes from a bake-off (tools/bakeoff) of the three pure Go libraries that can draw a PDF, on a hundred real files, with Poppler as the reference:

Library Errors Time for a page, median and 95% Memory, median Difference with the reference
folio none 12 ms and 160 ms 11 MB 0.85
Aspose.PDF FOSS none 72 ms and 623 ms 30 MB 1.05
go-pdfkit none 34 ms and 317 ms 22 MB 1.07

On a larger pile (317 files) folio drew one page very slowly (a page full of inline pictures took 23 seconds), showed wrong colours for JPEG pictures with four colour components and an embedded profile, and showed one layer that the file hides. The other two had blank pages, missing pictures or garbled letters. See tools/bakeoff/main.go for how to run it on your own files; the results name no file.

What is not there

Compared with SumatraPDF and Adobe Reader, pdf4win has no:

  • translations, the window is in English;
  • Explorer preview pane and thumbnails, which need a DLL that pure Go cannot build;
  • DDE commands, a policy file, custom themes, renaming a file or sending it by e-mail;
  • touch gestures, dragging tabs to another place or window, copying a selection as a picture, searching the selection on the web;
  • poster printing and a loupe;
  • redaction, signing, checking signatures, OCR and JavaScript;
  • XPS, DjVu, PostScript, RAR and 7z comic books and the rare kinds of JPEG named under "Formats".

Build (on Linux)

Install the tools once:

sudo apt install jq wixl msitools wine
go install github.com/tc-hib/go-winres@latest

The icon, manifest (visual styles, DPI awareness) and version info are compiled from winres/ into cmd/pdf4win/rsrc_windows_<arch>.syso, which is not committed. run.sh and release.sh generate it.

go test ./...
./run.sh [file]
./run.sh --demo

run.sh builds pdf4win.exe and runs it with Wine. PDF4WIN_THEME=dark ./run.sh shows the dark colours. Read aloud does not work under Wine, which has no voices.

The packages without a window (engine, view, tiles, pagetext, impose, search, synctex, config and the three adapters) are tested on any system. The drawing of printed pages is tested on Windows or Wine, against a bitmap in memory instead of a printer:

GOOS=windows go test -c -o ui.test.exe ./internal/ui
wine ui.test.exe

SyncTeX is tested against a file written by hand, not yet against the output of a TeX run.

The icon is winres/icon.svg; after changing it, run go run ./tools/genicon (needs Inkscape) to render the PNG files in winres/.

Release

./release.sh          # 0.1.0 -> 0.1.1 (build, the default)
./release.sh minor    # 0.1.1 -> 0.2.0
./release.sh major    # 0.2.0 -> 1.0.0
./release.sh msi      # only build the MSI of the current version

release.sh needs a clean working tree. It raises the version in winres/winres.json, checks the licenses, runs the tests, builds dist/pdf4win-<version>-amd64.msi, the portable dist/pdf4win-<version>-amd64.exe and dist/pdf4win-<version>-arm64.exe and dist/SHA256SUMS, commits and pushes the version bump and creates the GitHub release with those four files. wixl cannot build an arm64 MSI, so arm64 is only a portable exe. Besides the build tools above it needs the GitHub CLI (gh). The installer is defined in installer/pdf4win.wxs. release.sh signs the exes and the MSI with ssctl and the Certum certificate in SimplySign; run ssctl login first and log in with a token from the SimplySign mobile app. SimplySign Desktop is not needed.

Layout

  • internal/engine: the one interface between the program and the libraries: a document with pages, text, links, bookmarks, annotations and form fields, and the list of changes that a save writes. Everything is in points with the origin in the top left corner of the page as it is shown.
  • internal/folio, internal/pictures, internal/aspose: the adapters that put a library behind that interface, for reading documents, reading pictures and comic books, and writing PDF files.
  • internal/view: where the pages are in the window: the views, zoom, fit, rotation and scrolling. No user interface, tested on any platform.
  • internal/tiles: pages are drawn in tiles on a pool of workers, kept in a cache with a limit in bytes.
  • internal/pagetext: words and lines from the boxes of the characters, selection and find.
  • internal/impose: page ranges, pages on a sheet, booklets and the strips a page is printed in.
  • internal/search: find in the documents of a folder.
  • internal/shrink: a smaller copy of a file, checked page by page.
  • internal/pagesel: the selected pages of the side bar and their order.
  • internal/synctex: a reader for the SyncTeX files of LaTeX.
  • internal/ui: the window. app.go the window and its state, commands.go the one table of commands that the menus, the toolbar, the keys, the palette and the command line use, canvas.go and mouse.go the pages, annot.go annotations and forms, print.go, sidebar.go, tabstrip.go, toolbar.go, statusbar.go, home.go, find.go, folder.go, palette.go, latex.go, speech.go, instance.go, dialogs.go, theme.go light and dark.
  • internal/icons: the Fluent UI System Icons (MIT).
  • internal/config, internal/update: settings and the update check.
  • internal/notices: the licenses of the libraries, embedded in the exe.
  • internal/testpdf: the sample document of --demo and the tests.
  • tools/licenses: the license check. tools/bakeoff: the comparison of the libraries, a module of its own so that the losers stay out of go.mod. tools/genicon, tools/mkico: the icon.

License

MIT, see LICENSE. The icons are the Fluent UI System Icons of Microsoft, also MIT. The licenses of the libraries are in THIRD-PARTY-NOTICES.txt.

About

PDF reader for Windows with tabs, annotations, form filling and printing, written in Go

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages