How to open and display a PDF file using Qt / C ++?

I am trying to open and read a PDF file using Qt, but there is no concrete way to do this.

+4
source share
7 answers

I know the topic is a bit outdated, but ... I found a very easy way to render PDF files in Qt via QtWebKit using pdf.js ( http://mozilla.github.com/pdf.js/ ).

Here is my implementation of the idea for Qt5 and WebEngine: https://github.com/Archie3d/qpdf

+7
source
As far as I know, Qt itself does not include PDF reader / writer functions. Perhaps you should take a look at libpoppler , which has Qt bindings.
+3
source

I found this very interesting article on qt-project.org - "Processing a Qt PDF project."
This page discusses the various options available for working with PDF documents in the Qt application. The page doesn't exactly show how to "open and display an existing PDF document," but it will help you get something useful out of everything that is explained there.

Here on the page it says:

To display pages or elements from existing PDF documents into image files or images in memory (useful, for example, to create thumbnails or embed custom viewers), third-party libraries can be used (for example: poppler-qt4 (freedesktop.org) and muPDF (mupdf .com)).

Alternatively, the task can be delegated to an existing command line (for example, poppler-utils (freedesktop.org) and muPDF (mupdf.com)).

+2
source

You can use PdfViewer , which is a lightweight PDF viewer that uses only Qt. It contains a PdfView widget that can be easily PdfView into your application.

+2
source

The simple answer: it is not supported in the Qt API.

Another answer: you can encode it, I suggest you take a look at this Qt application that uses Ghostscript

0
source

The best way to find PDF is to use QProcess in Qt.

-1
source

Qt does not support reading PDF files out of the box, and among many approaches you can use the Adobe PDF Reader ActiveX object along with QAxObject.

You can check out this link, which describes how to read PDF files in Qt / C ++ using ActiveX and has a downloadable sample project.

-2
source

All Articles