0
votes

I'm in the process of writing an app in Electron. The app requires there to be a pdf rendered in a frame that takes up approximately 50% of the window. Because of the somewhat restricted space, I would like a solution that allows me to render a PDF without any frame, margin or controls bar around it. In macOS native apps, you have access to PDFView, which is a PDF renderer with nothing around it. I'm trying to find the closest thing to this, but for Node.js/Electron.

Before this gets marked as duplicate, I've read through a number of "Rendering PDF's in electron" posts on here. All of them pointed towards a number of libraries, notably "electron-pdf-window". The problem with the library is that all it does is wrap up "PDF.js". I've looked through PDF.js as well as the examples, but it also has the chrome-style frame and controls.

Are there any libraries/implementations of a PDF viewer for Node.js/Electron that provide a near-native (macOS) experience, in a "frameless" window? It needs to have copy/paste support, as well as support for trackpad gestures. Additionally, it should be able to support documents of at least a hundred pages.

Side question - Are you able to modify the default Chrome PDF viewer? (i.e remove the top "controls" bar, as well as trim down all the margins)? This seems like the fastest (most efficient) way to do it, but I'm not sure if it's possible.

1

1 Answers

0
votes

After some research and testing, I've found that you can make a very minimal version of PDF.js. The "pinch-to-zoom" functionality isn't as smooth as on a native app, but you can get fairly close if you use PDF.js' experimental SVG renderer.

Here are some examples of a full PDF viewer with no toolbar: https://github.com/mozilla/pdf.js/tree/master/examples/components