PdfViewer 101

This page shows how to get started with Wijmo's PdfViewer control.

Getting Started

Steps for getting started with the PdfViewer control in JavaScript applications:

  1. Set up C1 Web API PDFDocument Services. Please refer to How to set up C1 Web API PDFDocument Services.
  2. Add references to Wijmo.
  3. Add markup to serve as the Wijmo control's host.
  4. Initialize the Wijmo control(s) via JavaScript.
  5. (Optional) Add some CSS to customize the pdf viewer control's appearance.

The C1 Web API PDFDocument Services uses C1PdfDocumentSource to render and export pdf files. Please refer to How to set up C1 Web API PDFDocument Services for details.

To show the pdf file from C1 Web API PDFDocument Services, set the following basic properties:

  1. serviceUrl: The url of C1 Web API PDFDocument Services. For example, ''.
  2. filePath: The full path to the pdf file. For example, 'PdfRoot/DefaultDocument.pdf'.

    The 'PdfRoot' is the key of the pdf file disk storage provider, which is registered at server for locating the specified pdf file.
    The 'DefaultDocument.pdf' is the relative path of the pdf file, which can be located by the disk storage provider.

Result (live):

<div id="introPdfViewer"></div>
var introPdfViewer = new wijmo.viewer.PdfViewer('#introPdfViewer', { serviceUrl: serviceUrl, filePath: 'PdfRoot/DefaultDocument.pdf' });
.wj-viewer { display: block; width: 100%; }

Basic Features

The PdfViewer control has the following four basic properties, which allow you to customize its appearance and behavior:

The example below allows you to see what happens when you change these properties.

Result (live):

<div class="row"> <h4>Result (live):</h4> <div id="basicPdfViewer"></div> </div> <br /> <div class="row"> <div class="form-horizontal"> <div class="form-group"> <div class="col-md-3"> <div class="checkbox"> <label> <input id="basicContinuousViewMode" type="checkbox" /> Continuous View Mode </label> </div> </div> <div class="col-md-3"> <select id="basicMouseMode"> <option value="SelectTool" selected>SelectTool</option> <option value="MoveTool">MoveTool</option> <option value="RubberbandTool">RubberbandTool</option> <option value="MagnifierTool">MagnifierTool</option> </select> </div> <div class="col-md-2"> <div class="checkbox"> <label> <input id="basicFullScreen" type="checkbox" /> Full Screen </label> </div> </div> <div class="col-mod-4"> <label class="col-md-2 control-label">Zoom Factor</label> <div class="col-md-2"> <input id="basicZoomFactor" type="text" /> </div> </div> </div> </div> </div>
var basicPdfViewer = new wijmo.viewer.PdfViewer('#basicPdfViewer', { serviceUrl: serviceUrl, filePath: 'PdfRoot/DefaultDocument.pdf', zoomFactorChanged: function (s, e) { zoomFactor.value = s.zoomFactor; } }); // change viewer properties document.getElementById('basicFullScreen').addEventListener('click', function (e) { basicPdfViewer.fullScreen = e.target.checked; });; var mouseModeMenu = new wijmo.input.Menu('#basicMouseMode', { itemClicked: function (s, e) { basicPdfViewer.mouseMode = s.selectedValue; updateMenuHeader(s, 'Mouse Mode'); } }); updateMenuHeader(mouseModeMenu, 'Mouse Mode'); var zoomFactor = new wijmo.input.InputNumber('#basicZoomFactor', { min: 0.05, max: 10, step: 0.1, format: 'n2', value: basicPdfViewer.zoomFactor, valueChanged: function (s, e) { if (s.value >= s.min && s.value <= s.max) { basicPdfViewer.zoomFactor = s.value; } } }); document.getElementById('basicContinuousViewMode').addEventListener('click', function (e) { basicPdfViewer.viewMode = e.target.checked ? 'Continuous' : 'Single'; }); }