Need help with qtpdfium?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

paulovap
150 Stars 62 Forks BSD 3-Clause "New" or "Revised" License 41 Commits 16 Opened issues

Description

Pdf Redening on Qt

Services available

!
?

Need anything else?

Contributors list

# 12,219
gRPC
flatbuf...
c-plus-...
c-sharp
24 commits
# 258,463
C
c-plus-...
stm32
gdb
6 commits
# 430,767
Postgre...
C
postgre...
plpgsql
2 commits
# 537,906
Python
C++
Qt
Android
1 commit

QtPdfium

QtPdfium is a Qt module that renders PDF files using the pdfium project by google. It render PDF pages into QImage.

Installation

To use the library you must first install it in the same location as your Qt installation. Here is an example on Linux/Mac:

git clone --recursive https://github.com/paulovap/qtpdfium
cd qtpdfium
qmake
make
make install (might need sudo)

After that you are ready to use it. Remember to build for each platform you want. (Desktop, Android, iOS...)

Usage

The API consists in only two classes:

QPdfium
and
QPdfiumPage
.

To load a PDF file, simply do: ```cpp

include

QPdfium pdf("mypdf.pdf"); qDebug() << pdf.isValid(); //should return true ```

You can get the number of pages with

QPdfium::pageCount()

You can access pages by index:

#include 

QPdfium pdf("mypdf.pdf"); QPdfiumPage page = pdf.page(0); qDebug() << page.width(); // should show something!

To generate the image:

#include 

QPdfium pdf("mypdf.pdf"); QPdfiumPage page = pdf.page(0); QImage image = page.image(3); //renders it 3 times bigger

And for extracting text:

#include 

QPdfium pdf("mypdf.pdf"); QPdfiumPage page = pdf.page(0); QString pageText = page.text();

Note: On iOS you need to initialize QtPdfium manually since it is statically linked. Just create a global object like this:

#ifdef Q_OS_IOS
    //Since it's static library on IOS we need to initialize it by hand
    PdfiumGlobal global;
#endif

And that's it.

Future work

  • Load pdf with encryption (passwords)
  • Text manipulation (find, extract, cursor..)
  • Partial rendering
  • Render to other devices (gl surface, so on..)

Contributing

Feel free to help. :)

License

BSD

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.