Giter Site home page Giter Site logo

w1146869587 / qpdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from archie3d/qpdf

0.0 1.0 0.0 2.46 MB

PDF viewer widget for Qt

License: GNU Lesser General Public License v2.1

C++ 2.13% QMake 0.07% JavaScript 91.00% CSS 4.91% HTML 1.87% C 0.02%

qpdf's Introduction

QPdf

PDF viewer widget for Qt 5.

This is a wrapper of pdf.js JavaScript PDF renderer using Qt WebEngine.

Screenshot

This qmake-based project defines two build targets: qpdf shared library, and an example PDF viewer (pdfviewer) based on qpdf library. Should yoo want to integrate a PDF view into your project, you need to take qpdf library only, you do not need pdfviewer (though you may use it as inspirational example for your project). So you may copy qpdflib into your project and build it as a shared library to be linked with your code.

How to compile

  • Make sure you have Qt 5.9.x or later installed. Earlier Qt versions are not supported.
  • Open qpdf.pro project file in QtCreator
  • Build and run

Open PDF files

qpdf library offers two ways to open PDF files:

loadData method serializes PDF data as base64 string and injects it into JavaScript environment. This may fails however when loading huge PDF files.

loadFile can load PDFs of any size, however the method is blocked by default due to the cross-origin security restriction, since it uses WebEngine's load URL method. In order to make this method work, you have to disable web security by passing --disable-web-security argument to your QApplication instance (see how its done in pdfviwer example).

Debugging

If something goes wrong, as sometimes it does, you may use Chromium debug console to assess the situation:

  • Define QTWEBENGINE_REMOTE_DEBUGGING environment variable to activate WebEngine debug server, e.g. QTWEBENGINE_REMOTE_DEBUGGING=0.0.0.0:9999
  • Launch your qpdf-based application
  • Open Chrome or Chromium web browser and navigate to http://localhost:9999
  • Select the running application link in the browser and you will be presented with a familiar web page inspection console.

Qt Quick Compiler Issue

This project includes JavaScript *.js files as resources. Qt Creator may try to add them to QML resources instead, which makes the web engine unable to load *.js from normal resources. This happens on Windows in Release builds automatically (but not in Debug for some reason). Make sure to disable Qt Quick Compiler in your project build settings: Disable Qt Quick

qpdf's People

Contributors

archie3d avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.