develtar / qt-pdf-viewer-library

The qt-pdf-viewer-library is a qml wrapper of pdf.js library which allows you to render PDF files in a WebView. This library also works on Android devices, and it uses WebSocketServer, WebSocketTransport and WebChannel to exchange data between qml and the browser environment.
Apache License 2.0
41 stars 9 forks source link
android open-source opensource pdf pdf-viewer pdfjs qt qt5

Qt Pdf Viewer Library

license latest-release stars

device-android device-desktop code-size

The qt-pdf-viewer-library is a qml wrapper of pdf.js library which allows you to render PDF files in a WebView. This library also works for Android devices, and it uses WebSocketServer, WebSocketTransport and WebChannel to exchange data between qml and the browser environment.

1.0. Dependencies

The qt modules needed by the library are:

1.0.1. Libraries

The libraries used to create the qt-pdf-viewer-library are:

1.1. Testing

The qt-pdf-viewer-library has been tested on the following qt versions:

on the following Android devices:

and on the following os:

1.2. Usage

To use the qt-pdf-viewer-library in your app, follow these steps:


import it.ltdev.qt.qml.components 1.0 as LTDev

ApplicationWindow {
      ...

      LTDev.PdfView {
          id: pdfView

          anchors.fill: parent

          onViewerLoaded: {
              // Load pdf only when viewer is ready
              pdfView.load("path/to/my/document.pdf")
          }

          onPdfLoaded: {
              // Pdf has been correctly loaded
          }

          onError: {
             // Some error occurred
             console.error("Error: ", message)
          }
      }
}

1.3. PdfView

The provided PdfView exposes the following properties:

the following methods:

and the following signals:

1.4. Sample App

The sample app implements all operations provided by the library, like rotation, fit size dimensions, zoom in/out, change view visualization, text search and pages preview.

Below some screenshot for the desktop version: