Secure Web-Based PDF Viewer for Java

This web-based PDF viewer sample is created using a commercial library - GroupDocs.Viewer for Java. The sample allows you to:

  • Explore key features of the Java PDF viewer built using the library.
  • See how you can integrate it into your Java app to securely display PDF and other document types on the web.
  • Get an idea on how to build a custom Java PDF viewer tailored to your specific needs using the library.

Before proceeding, please note that GroupDocs.Viewer for Java is a paid library. This sample is created by the GroupDocs team as a showcase. The sample comes with a free evaluation version of the library that has several trial restrictions. If you’d like to test the Java PDF viewer without any limitations, please contact GroupDocs support for a free 30-day license.

Requirements Specification

  1. Security. Prevent unauthorized copying of the displayed PDF documents and restrict access to the original files stored on the server.
  2. Cross-platform compatibility. Allow users to view PDF documents from any web-enabled device and using any standard web-browser.
  3. Easy deployment. Avoid any client-side downloads or installations to minimize IT overhead.


There are two main approaches of building a web-based Java PDF viewer. The first is to transfer PDFs to clients and then visualize them in a browser. These types of viewers are usually easy to implement, but have a number of drawbacks. You can’t guarantee security of the displayed PDFs since they are downloaded to user machines. Also, end users are forced to install 3rd party software (e.g. browser plugins) required to view a PDF document.

The second approach is to convert source PDF documents to web-compatible content (HTML markup, CSS, raster or SVG images and JS), transfer it to clients and then render in a web-browser.

GroupDocs.Viewer for Java is a document viewer library developed using this second, client-server (or "thin client") approach. The library accurately converts PDF documents to web compatible content, so that web copies look undistinguished from the original files. The benefits are obvious:

  1. Original PDF documents stay on the server during view sessions. End users can’t access the documents unless you allow them to.
  2. The web copies of the PDF documents can be viewed in any standard web-browser that can handle HTML, CSS, JS and SVG or raster images. End users don’t have to install any plugins or 3rd party office software.
  3. Reduced IT overhead, as there is no need to maintain client applications and implement complex security systems to protect the displayed PDF documents from unauthorized copying.

Other features at a glance

Out-of-the-box Web GUI
GroupDocs.Viewer for Java comes with a customizable web user interface that allows end users to:

  • Scroll or turn PDF pages like slides
  • Preview and navigate pages using thumbnails
  • Search for text using key phrases (including exact phrase or any keyword match types)
  • Rotate, zoom in/out of the document or fit width/height
  • Print and download original documents

A comprehensive API allows you to add/remove toolbars, buttons, tweak UI’s layout & styles and embed it to you Java web app or website. Alternatively, you can build your own GUI from scratch.

Digital Rights Management
Although available by default, the print, download and text copy options can be disabled for all or specific documents, so that they are displayed in a "read-only" mode.

The viewer allows you to render custom watermarks over the displayed PDF documents to protect them from screen grabbing.

Multiple file formats support
In addition to PDF, GroupDocs.Viewer for Java supports Microsoft Word, Excel, PowerPoint, Visio and over 50 other common document and image types.

Useful Links

This sample covers only the core GroupDocs.Viewer for Java functionality. You can use the viewer as is, build a custom Java PDF viewer (or a multi-format document viewer) tailored to your specific needs and seamlessly integrate it into any web app or website. For more details on the library, please visit its homepage and extensive API documentation.

Also, we’ve prepared individual samples for Spring and Servlet. You can download them from this page.

Last edited Mar 30, 2015 at 8:27 AM by GroupDocs, version 5