Alternatively, configure npm to use your corporate registry or proxy, then install using the standard command.
Minimal JavaScript app example
Once you have installed the GroupDocs.Viewer package, here’s a minimal example of how you can use it in a Node.js application.
Create a JavaScript file (e.g., app.js) in your project’s root directory.
Import the GroupDocs.Viewer module and implement a simple file viewing functionality:
import{Viewer,HtmlViewOptions}from'@groupdocs/groupdocs.viewer';// Path to the file you want to render
constfilePath='sample.pdf';// Initialize viewer
constviewer=newViewer(filePath);// Render the file to HTML
viewer.view(HtmlViewOptions.forEmbeddedResources());// Exit with a success code
process.exit(0);
sample.pdf is the sample file used in this example. Click here to download it.
Run the app by executing the following command in your terminal:
node app.js
This minimal example converts a document to HTML format. The output will contain rendered pages in HTML format.
Troubleshooting installation
node-gyp toolchain not found: install the required build tools for your OS (see System Requirements).
Java not detected: set JAVA_HOME and add <JAVA_HOME>/bin to PATH.
Corporate proxy: configure npm proxy settings before running install.
Permission errors: ensure you have write access to the project directory and cache folders.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.