|
| 1 | +# PSPDFKit for Electron Example App |
| 2 | + |
| 3 | +This example shows how to build a [PSPDFKit for Electron](https://www.nutrient.io/electron/) application with |
| 4 | +[Electron](https://electronjs.org/). |
| 5 | + |
| 6 | +This example uses node integration. If you're looking for an example with context isolation enabled, and node integration disabled, you can switch to the [`master` branch](https://github.com/PSPDFKit/pspdfkit-electron-example/tree/master). |
| 7 | + |
| 8 | +## Prerequisites |
| 9 | + |
| 10 | +- [Node.js](http://nodejs.org/) |
| 11 | + |
| 12 | +## Support and Issues |
| 13 | + |
| 14 | +Are you [evaluating our SDK](https://www.nutrient.io/try/)? That's great, we're happy to help out! To make sure this is fast, please use a work email and have someone from your company fill out our sales form: https://www.nutrient.io/sales/ |
| 15 | + |
| 16 | +## Getting Started |
| 17 | + |
| 18 | +Clone the repo: |
| 19 | + |
| 20 | +```bash |
| 21 | +git clone https://github.com/PSPDFKit/pspdfkit-electron-example.git |
| 22 | +cd pspdfkit-electron-example |
| 23 | +``` |
| 24 | + |
| 25 | +Install the project dependencies with `npm`: |
| 26 | + |
| 27 | +```bash |
| 28 | +npm install |
| 29 | +``` |
| 30 | + |
| 31 | +**Important:** If you are using Windows, do not use PowerShell. Instead, use Microsoft’s [Developer Command Prompt for Visual Studio](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs). |
| 32 | + |
| 33 | +## Running the Example |
| 34 | + |
| 35 | +We are ready to launch the app! 🎉 |
| 36 | + |
| 37 | +```bash |
| 38 | +npm run start |
| 39 | +``` |
| 40 | + |
| 41 | +The Electron application will automatically start. |
| 42 | + |
| 43 | +To open the developer tools inside Electron, uncomment the following line in `index.js`: |
| 44 | + |
| 45 | +```js |
| 46 | +// Open the DevTools. |
| 47 | +mainWindow.webContents.openDevTools(); |
| 48 | +``` |
| 49 | + |
| 50 | +## What's in This Repository |
| 51 | + |
| 52 | +This repository contains an example integration of [PSPDFKit for Electron](https://www.nutrient.io/electron). The project structure is influenced by the default Electron example app and comes with the following files: |
| 53 | + |
| 54 | +| Filename | Description | |
| 55 | +| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 56 | +| `src/index.js` | The main entry point used to create the Electron windows. This file does not contain major changes, with the exception of a validation to make sure that PSPDFKit is properly installed. It is responsible for loading `src/index.html`. | |
| 57 | +| `src/index.html` | The main HTML entry point. It will set up a simple HTML structure and invoke the JavaScript that runs in the renderer thread: `src/renderer.js`. | |
| 58 | +| `src/renderer.js` | This file is where we import PSPDFKit and set it up properly. We use it to extend Nutrient Web SDK with custom behavior. | |
| 59 | + |
| 60 | +## Build Production Packages |
| 61 | + |
| 62 | +We recommend using [`electron-packager`](https://github.com/electron-userland/electron-packager) or a similar solution to build the production bundles. |
| 63 | + |
| 64 | +### Install `electron-packager` |
| 65 | + |
| 66 | +```bash |
| 67 | +npm install -g electron-packager |
| 68 | +``` |
| 69 | + |
| 70 | +### Build Individual Packages |
| 71 | + |
| 72 | +The following code will only work on macOS. For other platforms, please consult the [documentation](https://github.com/electron-userland/electron-packager#electron-packager) of `electron-packager`: |
| 73 | + |
| 74 | +```bash |
| 75 | +npm run package-mac-intel |
| 76 | +npm run package-mac-apple (Apple Silicon) |
| 77 | +npm run package-win (requires Wine: `brew cask install xquartz`, `brew install wine`) |
| 78 | +npm run package-linux (requires `apt-get install libgconf-2-4` on target Linux) |
| 79 | +``` |
| 80 | + |
| 81 | +## License |
| 82 | + |
| 83 | +This software is licensed under a [modified BSD license](LICENSE). |
| 84 | + |
| 85 | +## Contributing |
| 86 | + |
| 87 | +Please ensure |
| 88 | +[you have signed our CLA](https://www.nutrient.io/guides/web/current/miscellaneous/contributing/) so that we can |
| 89 | +accept your contributions. |
0 commit comments