Top Related Projects
qpdf: A content-preserving PDF document transformer
A Python library for reading and writing PDF, powered by QPDF
PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.
Community maintained fork of pdfminer - we fathom PDF
iText for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText can be a boon to nearly every workflow.
PDF Reader in JavaScript
Quick Overview
PDF4QT is an open-source PDF library and toolkit for Qt, written in C++. It provides a comprehensive set of tools for reading, writing, and manipulating PDF documents, as well as a collection of GUI applications for various PDF-related tasks.
Pros
- Extensive functionality for PDF manipulation and rendering
- Cross-platform compatibility due to Qt framework
- Actively maintained with regular updates
- Includes both a library and ready-to-use applications
Cons
- Requires Qt framework, which may increase project size and complexity
- Documentation could be more comprehensive
- Limited support for some advanced PDF features
- Steeper learning curve compared to some other PDF libraries
Code Examples
- Opening a PDF file:
#include <PDFDocument.h>
PDFDocument document;
if (document.load("example.pdf"))
{
// PDF loaded successfully
}
- Extracting text from a page:
#include <PDFTextExtractor.h>
PDFTextExtractor extractor(&document);
QString text = extractor.extractText(0); // Extract text from the first page
- Creating a new PDF document:
#include <PDFWriter.h>
PDFWriter writer;
writer.createDocument();
writer.addPage(PDFPageFormat::A4);
writer.writeText("Hello, World!", 100, 700);
writer.save("output.pdf");
Getting Started
To use PDF4QT in your project:
-
Clone the repository:
git clone https://github.com/JakubMelka/PDF4QT.git
-
Build the library using CMake:
mkdir build && cd build cmake .. make
-
Include the necessary headers in your C++ file:
#include <PDFDocument.h> #include <PDFWriter.h>
-
Link against the PDF4QT library in your CMakeLists.txt:
target_link_libraries(your_target PRIVATE PDF4Qt)
-
Start using PDF4QT functions in your code as shown in the examples above.
Competitor Comparisons
qpdf: A content-preserving PDF document transformer
Pros of qpdf
- More mature and established project with a longer history
- Extensive command-line interface for PDF manipulation
- Supports a wider range of PDF operations and transformations
Cons of qpdf
- Primarily a C++ library, which may limit integration options for some developers
- Less focus on GUI applications compared to PDF4QT
- Steeper learning curve for beginners due to its comprehensive feature set
Code Comparison
qpdf:
QPDF pdf;
pdf.processFile("input.pdf");
QPDFWriter w(pdf, "output.pdf");
w.setStreamDataMode(qpdf_s_compress);
w.write();
PDF4QT:
PDFDocument document;
document.load("input.pdf");
PDFWriter writer(&document);
writer.write("output.pdf");
Summary
qpdf is a powerful, command-line focused PDF library with extensive manipulation capabilities. It offers a wide range of features but may be more complex for beginners. PDF4QT, on the other hand, is designed with Qt integration in mind, making it more suitable for GUI applications and potentially easier for developers familiar with the Qt framework. Both libraries provide PDF manipulation functionality, but their focus and target use cases differ.
A Python library for reading and writing PDF, powered by QPDF
Pros of pikepdf
- Python-based library, making it accessible to a wider range of developers
- Extensive documentation and active community support
- Lightweight and focused specifically on PDF manipulation
Cons of pikepdf
- Limited GUI capabilities compared to PDF4QT
- May require additional libraries for advanced features
- Less comprehensive in terms of overall PDF functionality
Code Comparison
PDF4QT (C++):
PDFDocument doc;
doc.load("input.pdf");
PDFPage* page = doc.getPage(0);
page->addText("Hello, World!", 100, 100);
doc.save("output.pdf");
pikepdf (Python):
import pikepdf
pdf = pikepdf.Pdf.open("input.pdf")
page = pdf.pages[0]
page.add_text("Hello, World!", x=100, y=100)
pdf.save("output.pdf")
Summary
PDF4QT is a comprehensive C++ library with GUI capabilities, while pikepdf is a lightweight Python library focused on PDF manipulation. PDF4QT offers more extensive features but may have a steeper learning curve. pikepdf is more accessible to Python developers and has strong community support, but may require additional libraries for advanced functionality.
PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.
Pros of PyMuPDF
- More extensive documentation and examples
- Broader platform support (Windows, macOS, Linux, iOS, Android)
- Larger community and more frequent updates
Cons of PyMuPDF
- Steeper learning curve for beginners
- Licensing may be more restrictive for commercial use
- Larger file size and memory footprint
Code Comparison
PyMuPDF:
import fitz
doc = fitz.open("example.pdf")
page = doc[0]
text = page.get_text()
PDF4QT:
#include <PDFDocument.h>
PDFDocument document("example.pdf");
PDFPage* page = document.getPage(0);
QString text = page->getText();
PyMuPDF offers a more concise Python API, while PDF4QT provides a C++ interface with Qt integration. PyMuPDF's approach may be more accessible for Python developers, whereas PDF4QT might be preferred in Qt-based applications or when C++ is the primary language.
Community maintained fork of pdfminer - we fathom PDF
Pros of pdfminer.six
- Written in Python, making it more accessible for Python developers
- Extensive documentation and community support
- Lightweight and easy to integrate into existing Python projects
Cons of pdfminer.six
- Limited functionality compared to PDF4QT's comprehensive feature set
- Slower performance for large PDF files
- Less frequent updates and maintenance
Code Comparison
pdfminer.six:
from pdfminer.high_level import extract_text
text = extract_text('sample.pdf')
print(text)
PDF4QT:
#include <pdf4qt/pdfdocument.h>
PDFDocument document("sample.pdf");
QString text = document.getText();
qDebug() << text;
Summary
pdfminer.six is a Python-based PDF parsing library, while PDF4QT is a C++ library with Qt integration. pdfminer.six offers simplicity and ease of use for Python developers, but PDF4QT provides more comprehensive features and better performance for large files. The choice between the two depends on the specific project requirements, programming language preference, and performance needs.
iText for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText can be a boon to nearly every workflow.
Pros of itext-java
- More mature and widely adopted library with extensive documentation
- Supports a broader range of PDF manipulation features
- Active community and regular updates
Cons of itext-java
- Commercial licensing required for certain use cases
- Steeper learning curve due to its comprehensive feature set
- Larger footprint and potential performance overhead
Code Comparison
itext-java:
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);
document.add(new Paragraph("Hello World!"));
document.close();
PDF4QT:
PDFDocument document;
PDFPage* page = document.createPage(QSizeF(595, 842));
PDFTextObject* text = new PDFTextObject(page);
text->setText("Hello World!");
page->addObject(text);
Summary
itext-java is a more established and feature-rich PDF library for Java, offering extensive capabilities but with potential licensing and complexity considerations. PDF4QT, on the other hand, is a Qt-based C++ library that may provide a simpler approach for basic PDF operations, particularly in Qt-based applications. The choice between the two depends on the specific project requirements, programming language preference, and licensing considerations.
PDF Reader in JavaScript
Pros of pdf.js
- Written in JavaScript, making it highly portable and easy to integrate into web applications
- Extensive browser compatibility, including mobile devices
- Large community support and regular updates due to Mozilla backing
Cons of pdf.js
- Limited features compared to native PDF readers
- Performance can be slower for large or complex PDF files
- Lacks advanced PDF editing capabilities
Code Comparison
PDF4QT (C++):
void PDFRenderer::renderPage(int pageNumber, QPainter* painter, qreal zoom)
{
PDFPage* page = m_document->getPage(pageNumber);
page->render(painter, zoom);
}
pdf.js (JavaScript):
pdfjsLib.getDocument(url).promise.then(function(pdf) {
pdf.getPage(1).then(function(page) {
var scale = 1.5;
var viewport = page.getViewport({scale: scale});
page.render({canvasContext: context, viewport: viewport});
});
});
Summary
PDF4QT is a Qt-based PDF library written in C++, offering native performance and integration with Qt applications. It provides more advanced features and better performance for complex PDFs. On the other hand, pdf.js is a JavaScript-based PDF renderer that excels in web environments, offering broad compatibility and easy integration into web applications. While pdf.js may have performance limitations for large files, it benefits from extensive community support and regular updates from Mozilla.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PDF4QT
(c) Jakub Melka 2018-2025
This software is consisting of PDF rendering library, and several applications, such as advanced document viewer, command line tool, and document page manipulator application. Software is implementing PDF functionality based on PDF Reference 2.0. It is written and maintained by Jakub Melka.
Software works on Microsoft Windows / Linux.
Software is provided without any warranty of any kind.
Should you find this software beneficial, your support would be greatly appreciated :heart: Sponsor!
1. ACKNOWLEDGEMENTS
This software is based in part on the work of the Independent JPEG Group.
Portions of this software are copyright © 2019 The FreeType Project (www.freetype.org). All rights reserved.
2. LEGAL ISSUES
This software was originally licensed under the GNU Lesser General Public License version 3 (LGPLv3). As of April 27, 2025, the project has been relicensed under the MIT License by the original author. The change to the MIT License was made to provide greater freedom and flexibility for both open-source and commercial use, reduce legal complexity, and encourage broader adoption and contribution.
Please see the attached LICENSE.txt file for details.
This software also uses several third-party libraries, and users must comply with the licenses of those third-party components.
3. FEATURES
Software have following features (the list is not complete):
- multithreading support
- encryption
- color management
- optional content handling
- text layout analysis
- signature validation
- annotations
- form filling
- text to speech capability
- editation
- file attachments
- optimalization (compressing documents)
- command line tool
- audio book conversion
- internal structure inspector
- compare documents
- static XFA support (readonly, simple XFA only)
- electronically/digitally sign documents
- public key security encryption
4. THIRD PARTY LIBRARIES
Several third-party libraries are used.
- libjpeg, see https://www.ijg.org/
- FreeType, see https://www.freetype.org/index.html, FTL license used
- OpenJPEG, implementing Jpeg2000, see https://www.openjpeg.org/, 2-clause MIT license
- Qt, https://www.qt.io/, LGPL license used
- OpenSSL, https://www.openssl.org/, Apache 2.0 license
- LittleCMS, http://www.littlecms.com/
- zlib, https://zlib.net/
- Blend2D, https://blend2d.com/
5. CONTRIBUTIONS
Contributions are welcome!
Since the project is now licensed under the MIT License, contributions can be freely submitted without the need to sign a Contributor License Agreement (CLA). However, all contributions must be made under the terms of the MIT License to ensure license consistency across the project.
You are encouraged to contribute by testing, offering feedback, providing advice, or submitting code improvements.
6. INSTALLING
Windows
The Release page lists binaries for Windows, both with and without an installer.
Arch Linux
A pdf4qt-git package is available in the AUR.
Linux - Flatpak/AppImage
For other Linux distributions, there are two options available. A Flatpak package can be accessed at Flathub. Alternatively, an AppImage is available in the Releases section. The AppImage format is designed to work on nearly all Linux systems. Historically, a .deb package was also offered, but it has been discontinued due to compatibility issues with some Linux distributions. The executable names are: Pdf4QtEditor, Pdf4QtDiff, Pdf4QtLaunchPad, Pdf4QtPageMaster, Pdf4QtViewer, and PdfTool.
7. COMPILING
This software can be compiled on both Windows and Linux. A compiler supporting the C++20 standard is needed.
On Windows, you can use Visual Studio 2022 or MinGW.
On Linux, a GCC version >= 8 should work, altough we tested it with GCC 11.
Compiling from sources
-
Install vcpkg
git clone https://github.com/Microsoft/vcpkg.git ./vcpkg/bootstrap-vcpkg.sh -disableMetrics VCPKG_ROOT=$(pwd)/vcpkg
Check that vcpkg path is correct:
$VCPKG_ROOT/vcpkg --version
. -
Build PDF4QT
2.1 Clone repo
git clone https://github.com/JakubMelka/PDF4QT cd PDF4QT
2.2 Configure
cmake -B build -S . -DPDF4QT_INSTALL_QT_DEPENDENCIES=0 -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX='/' -DCMAKE_BUILD_TYPE=Release
For a debug build, append
-DCMAKE_BUILD_TYPE=Debug
.It is recommended to set the VCPKG_OVERLAY_PORTS variable to 'PDF4QT/vcpkg/overlays' to prevent crashes due to the incompatible LIBPNG library on some Linux systems.
2.3 Build
cmake --build build
Use the
-j
switch to build multiple files in parallel.2.4 Install
sudo cmake --install build
To uninstall, run
sudo xargs rm < ./build/install_manifest.txt
.
Using Qt Creator (both Windows/Linux)
- Download Qt 6.6 or higher, and VCPKG package manager (https://vcpkg.io/en/index.html)
- Open Qt Creator and configure the project
- Build
CMAKE Compilation Options
Several important compilation options are available and should be set before building. On Windows, CMake can prepare a Wix project to create a *.msi installer package.
Option | Platform | Description |
---|---|---|
PDF4QT_INSTALL_MSVC_REDISTRIBUTABLE | Windows | Includes MSVC redistributable in installation |
PDF4QT_INSTALL_PREPARE_WIX_INSTALLER | Windows | Prepare .msi installator using Wix installer |
PDF4QT_INSTALL_DEPENDENCIES | Any | Install dependent libraries into installation directory |
PDF4QT_INSTALL_QT_DEPENDENCIES | Any | Install Qt dependent libraries into installation directory |
VCPKG_OVERLAY_PORTS | Linux | Set it to prevent crashes with incompatible libpng library |
Following important variables should be set or checked before any attempt to compile this project:
Variable | Platform | Description |
---|---|---|
PDF4QT_QT_ROOT | Any | Qt installation directory |
QT_CREATOR_SKIP_VCPKG_SETUP | Any | Enable or disable automatic vcpkg setup |
CMAKE_PROJECT_INCLUDE_BEFORE | Any | Should be set to package manager auto setup |
CMAKE_TOOLCHAIN_FILE | Any | Should be set to toolchain |
CMAKE_BUILD_TYPE | Any | Can be Release (default) or Debug |
Sample setup on Windows
Following set of variables gives sample setup for MS Windows. It is minimal initial configuration to be able to built Debug build on MS Windows.
Key | Value |
---|---|
CMAKE_BUILD_TYPE | Debug |
CMAKE_CXX_COMPILER | %{Compiler:Executable:Cxx} |
CMAKE_C_COMPILER | %{Compiler:Executable:C} |
CMAKE_GENERATOR | Ninja |
CMAKE_PREFIX_PATH | %{Qt:QT_INSTALL_PREFIX} |
CMAKE_PROJECT_INCLUDE_BEFORE | %{IDE:ResourcePath}/package-manager/auto-setup.cmake |
CMAKE_TOOLCHAIN_FILE | %{Qt:QT_INSTALL_PREFIX}/lib/cmake/Qt6/qt.toolchain.cmake |
PDF4QT_QT_ROOT | C:/Programming/Qt/6.4.0/msvc2019_64 |
QT_QMAKE_EXECUTABLE | %{Qt:qmakeExecutable} |
Tested Compilers - Windows
- Visual Studio 2022 (Microsoft Visual C++ Compiler 17.1)
- MinGW 11.2.0
Tested Compilers - Linux
- GCC 13.1.1
8. DISCLAIMER
I wrote this project in my free time. I hope you will find it useful!
Top Related Projects
qpdf: A content-preserving PDF document transformer
A Python library for reading and writing PDF, powered by QPDF
PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.
Community maintained fork of pdfminer - we fathom PDF
iText for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText can be a boon to nearly every workflow.
PDF Reader in JavaScript
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot