Git Product home page Git Product logo

qtpdfium's Introduction

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:

#include <QtPdfium/QPdfium>

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 <QtPdfium/QPdfium>

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

To generate the image:

#include <QtPdfium/QPdfium>

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

And for extracting text:

#include <QtPdfium/QPdfium>

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

qtpdfium's People

Contributors

ekoczwara avatar paulovap avatar pierreducroquet avatar pinaraf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtpdfium's Issues

Add to project from source

Undefined symbols for architecture x86_64:
"_CFRelease", referenced from:
CPDF_Type1Font::SetExtGID(char const*, int) in cpdf_type1font.o
"_CFStringCreateWithCStringNoCopy", referenced from:
CPDF_Type1Font::SetExtGID(char const*, int) in cpdf_type1font.o
"_CGFontGetGlyphWithGlyphName", referenced from:
CPDF_Type1Font::SetExtGID(char const*, int) in cpdf_type1font.o
"CFX_GEModule::InitPlatform()", referenced from:
CFX_GEModule::Init(char const**, CCodec_ModuleMgr*) in cfx_gemodule.o
"CFX_GEModule::DestroyPlatform()", referenced from:
CFX_GEModule::~CFX_GEModule() in cfx_gemodule.o
"CFX_FaceCache::RenderGlyph_Nativetext(CFX_Font const*, unsigned int, CFX_Matrix const*, int, int)", referenced from:
CFX_FaceCache::LoadGlyphBitmap(CFX_Font const*, unsigned int, bool, CFX_Matrix const*, int, int, int&) in cfx_facecache.o
"IFX_SystemFontInfo::CreateDefault(char const**)", referenced from:
_FPDF_GetDefaultSystemFontInfo in fpdf_sysfontinfo.o
"CFX_AggDeviceDriver::InitPlatform()", referenced from:
CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap*, bool, CFX_DIBitmap*, bool) in fx_agg_driver.o
"CFX_AggDeviceDriver::DrawDeviceText(int, FXTEXT_CHARPOS const*, CFX_Font*, CFX_Matrix const*, float, unsigned int)", referenced from:
vtable for CFX_AggDeviceDriver in fx_agg_driver.o
"CFX_AggDeviceDriver::DestroyPlatform()", referenced from:
CFX_AggDeviceDriver::~CFX_AggDeviceDriver() in fx_agg_driver.o
"CFX_Font::ReleasePlatformResource()", referenced from:
CFX_Font::~CFX_Font() in cfx_font.o
"CQuartz2D::CreateFont(unsigned char const*, unsigned int)", referenced from:
CPDF_Type1Font::LoadGlyphMap() in cpdf_type1font.o
"_kCFAllocatorDefault", referenced from:
CPDF_Type1Font::SetExtGID(char const*, int) in cpdf_type1font.o
"_kCFAllocatorNull", referenced from:
CPDF_Type1Font::SetExtGID(char const*, int) in cpdf_type1font.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Errors while building examples

I followed the installation instructions in the README file, nevertheless, i get some errors after loading the example project and my attempt to build the project. I'm using Qt5.9 on linux opensuse 42.2.
This is the output:

👎 Warnung: libicui18n.so.52.1, needed by /opt/Qt5.9/5.9/Src/qtpdfium/lib/libQt5Pdfium.so, may conflict with libicui18n.so.56
👎 Fehler: /opt/Qt5.9/5.9/Src/qtpdfium/lib/libQt5Pdfium.so: undefined reference to symbol 'ucal_getTimeZoneDisplayName_52_1'
/usr/lib64/libicui18n.so.52.1:-1: Fehler: error adding symbols: DSO missing from command line
👎 Fehler: collect2: error: ld returned 1 exit status

PDF to QPainter calls or SVG?

There is a high-quality BSD-licensed PDFium parsing and rendering library, maintained by Google and originated at Foxkit:
[1]: https://pdfium.googlesource.com/pdfium/

Qt has recently published a "labs module" to render a PDF into a QImage using the PDFium library:
[2]: http://blog.qt.io/blog/2017/01/30/new-qtpdf-qtlabs-module/
[3]: https://github.com/qt-labs/qtpdf

There is also another Qt-based similar project, QtPDFium:
[4]: https://github.com/paulovap/qtpdfium

There is also the Google Skia library, a performant 2D graphics library, also opensource:
[5]: https://skia.org
[6]: https://github.com/google/skia
[7]: https://skia.org/user/api/skcanvas

Now, PDFium has a Skia backend, which means that it can render a PDF onto an SkCanvas canvas:
[8]: https://pdfium.googlesource.com/pdfium/+/master/core/fxge/skia/
[9]: https://github.com/amplab/ray-core/blob/master/src/examples/ui/pdf_viewer/pdf_viewer.cc

And on the other hand, Skia has an SkSVGCanvas backend, which can render an SkCanvas into SVG:
[10]: https://github.com/google/skia/tree/master/include/svg
[11]: https://github.com/google/skia/tree/master/src/svg
[12]: https://github.com/google/skia/blob/master/include/svg/SkSVGCanvas.h
[13]: https://github.com/google/skia/blob/master/src/svg/SkSVGCanvas.cpp

And this seems to be a project that translates QPainter API calls to Skia API calls:
[14]: https://github.com/telishev/sneakPic/blob/master/src/renderer/qt2skia.h
[15]: https://github.com/telishev/sneakPic/blob/master/src/renderer/qt2skia.cpp
[16]: https://github.com/telishev/sneakPic
[17]: https://github.com/telishev/sneakPic/blob/master/src/renderer/renderer_item_svg.cpp

The qt2skia.cpp looks very trivial.

There seem to be several options:

  1. Bundle Skia with the Qt app and use [the Skia backend of PDFium][8] to render the PDF via PDFium onto a Skia canvas, and then use [SkSVGCanvas][10] to generate an SVG from the Skia canvas, which then can be consumed by the Qt app. This would have the advantage of actually being free from any Qt dependencies, i.e. one could make a "sk-pdf2svg" commandline app that converts PDF to SVG via PDFium+Skia.

  2. Bundle Skia with the Qt app, use [PDFium+Skia][8] to render the PDF via PDFium onto a Skia canvas, and then adapt [qt2skia][17] to do the reverse (translate Skia canvas API calls to QPainter API calls).

  3. Skip Skia altogether, and develop a QPainter backend for PDFium modeled after [the Skia backend of PDFium][8].

If anyone is up to doing any of the above and publishes the results under a liberal opensource license, I’ll be most happy.

build ios

can i build qtpdfium on iOS platform ?

Severe Memoryleaks

Hello,
sorry I can't submit a Patch at this time, but qtpdfium is leaking around 20MByte for every document.
Reason for this is a missing FPDF_ClosePage(m_page) in the QPdfiumPage deconstructor!

The QPdfium deconstructor should be like

for(auto xPage: m_pages){
 xPage.reset(); // remove reference, invokes deconstructor
 m_pages.clear();
}
if(m_document)
 ....

Note: We need to free the pages BEFORE we close the document.

Without the change Pdfium itself leaks around 56000 allocations!

Simliar should be done in setFileName()

What is the license for qtpdfium ?

Hello, there doesn't seem to be any license information for qtpdfium. Can you add the usual README.md, and/or LICENSE file, and license+copyright headers in the .cpp/.h files ?

Thanks !

SIGSEGV on CPDF_ColorSpace::GetBufSize()

Hello, Paulo!
I am trying to test your library. I added it to my qt project, but when I try to test it work using your sample code in REDME.MD, it crashes. Consider this data

Stack trace:
1 CPDF_ColorSpace::GetBufSize cpdf_colorspace.cpp 411 0x5555559be96a
2 CPDF_ColorSpace::CreateBuf cpdf_colorspace.cpp 418 0x5555559be99e
3 CPDF_Color::SetColorSpace cpdf_color.cpp 65 0x5555559bd60b
4 CPDF_ColorState::ColorData::SetDefault cpdf_colorstate.cpp 152 0x5555559c33b7
5 CPDF_ColorState::SetDefault cpdf_colorstate.cpp 25 0x5555559c2ce2
6 CPDF_ContentParser::Continue cpdf_contentparser.cpp 170 0x5555559c64c3
7 CPDF_PageObjectHolder::ContinueParse cpdf_pageobjectholder.cpp 33 0x5555557b953b
8 CPDF_Page::ParseContent cpdf_page.cpp 99 0x5555557b7239
9 FPDF_LoadPage fpdfview.cpp 636 0x5555557afbbc
10 QPdfium::page qpdfium.cpp 109 0x5555557a9af2
11 main main.cpp 46 0x5555556c5075

int CPDF_ColorSpace::GetBufSize() const {
  if (m_Family == PDFCS_PATTERN) { // Crashes when debugger gets here
    return sizeof(PatternValue);
  }
  return m_nComponents * sizeof(FX_FLOAT);
}

main.cpp:

#include <QApplication>
#include <QtPdfium>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QPdfium pdf;
     auto result = pdf.loadFile("path/to/some/file"); // Returns success
    auto pdfPage = pdf.page(0); // Crashes here 
    auto valid = pdfPage.isValid();
    return a.exec();
}

test fail on windows

Hello, I see two following testcases of failure here on windows msvc2015 win32 build.

********* Start testing of CppTest *********
Config: Using QtTest library 5.6.2, Qt 5.6.2 (i386-little_endian-ilp32 shared (dynamic) debug build; by MSVC 2015)
PASS   : CppTest::initTestCase()
FAIL!  : CppTest::test_protectedPdf() Compared values are not the same
d:\mypdf\tests\auto\cpp\tst_cpp.cpp(67) : failure location
QFATAL : CppTest::test_documentDeletion() ASSERT: "i < m_pageCount && i >=0" in file d:\mypdf\src\pdfium\qpdfium.cpp, line 104
FAIL!  : CppTest::test_documentDeletion() Received a fatal error.
Unknown file(0) : failure location
Totals: 1 passed, 2 failed, 0 skipped, 0 blacklisted
********* Finished testing of CppTest *********

Here I try build qtpdfium using lastest git qtpdfium and pdfium master branch as of git 2eb1a705c243b2d5ab912268dd453f5ade075b6f .
I make some patch change here to make this build on windows.

diff -ENwbur "a/qtpdfium/src/3rdparty/fxcrt.pri" ./3rdparty/fxcrt.pri
--- "b/qtpdfium/src/3rdparty/fxcrt.pri"	2017-02-12 12:35:02.326423100 +0700
+++ ./3rdparty/fxcrt.pri	2017-02-12 14:57:38.163318700 +0700
@@ -2,7 +2,7 @@
 SOURCE_DIR = $$PWD/pdfium
 
 PRIVATE_HEADERS += \
-$$SOURCE_DIR/core/fxcrt/fxcrt_qt.h \
+#$$SOURCE_DIR/core/fxcrt/fxcrt_qt.h \
 $$SOURCE_DIR/core/fxcrt/cfx_maybe_owned.h \
 $$SOURCE_DIR/core/fxcrt/cfx_observable.h \
 $$SOURCE_DIR/core/fxcrt/cfx_retain_ptr.h \
@@ -28,7 +28,7 @@
 $$SOURCE_DIR/core/fxcrt/xml_int.h
 
 SOURCES += \
-$$SOURCE_DIR/core/fxcrt/fxcrt_qt.cpp \
+#$$SOURCE_DIR/core/fxcrt/fxcrt_qt.cpp \
 $$SOURCE_DIR/core/fxcrt/fx_basic_array.cpp \
 $$SOURCE_DIR/core/fxcrt/fx_basic_bstring.cpp \
 $$SOURCE_DIR/core/fxcrt/fx_basic_buffer.cpp \
diff -ENwbur "a/qtpdfium/src/3rdparty/fxge.pri" ./3rdparty/fxge.pri
--- "b/qtpdfium/src/3rdparty/fxge.pri"	2017-02-12 12:35:02.373223200 +0700
+++ ./3rdparty/fxge.pri	2017-02-12 16:21:39.637575100 +0700
@@ -42,7 +42,6 @@
 $$SOURCE_DIR/core/fxge/android/cfpf_skiafont.cpp \
 $$SOURCE_DIR/core/fxge/android/cfpf_skiafontmgr.cpp \
 $$SOURCE_DIR/core/fxge/android/cfx_androidfontinfo.cpp \
-# $$SOURCE_DIR/core/fxge/android/fx_android_imp.cpp \
 $$SOURCE_DIR/core/fxge/dib/fx_dib_composite.cpp \
 $$SOURCE_DIR/core/fxge/dib/fx_dib_convert.cpp \
 $$SOURCE_DIR/core/fxge/dib/fx_dib_engine.cpp \
@@ -83,8 +82,27 @@
 $$SOURCE_DIR/core/fxge/ge/fx_ge_fontmap.cpp \
 $$SOURCE_DIR/core/fxge/ge/fx_ge_linux.cpp \
 $$SOURCE_DIR/core/fxge/ge/fx_ge_text.cpp \
-$$SOURCE_DIR/core/fxge/ge/fx_ge_qt.cpp \
+#$$SOURCE_DIR/core/fxge/ge/fx_ge_qt.cpp \
 $$SOURCE_DIR/core/fxge/agg/fx_agg_driver.cpp \
 $$SOURCE_DIR/core/fxge/ifx_renderdevicedriver.cpp
 
+android*{
+SOURCES += \
+	$$SOURCE_DIR/core/fxge/android/fx_android_imp.cpp 
+}
 
+win32{
+SOURCES += \
+	$$SOURCE_DIR/core/fxge/win32/cfx_psrenderer.cpp \
+      $$SOURCE_DIR/core/fxge/win32/cpsoutput.cpp \
+      $$SOURCE_DIR/core/fxge/win32/fx_win32_device.cpp \
+      $$SOURCE_DIR/core/fxge/win32/fx_win32_dib.cpp \
+      $$SOURCE_DIR/core/fxge/win32/fx_win32_dwrite.cpp \
+      $$SOURCE_DIR/core/fxge/win32/fx_win32_gdipext.cpp \
+      $$SOURCE_DIR/core/fxge/win32/fx_win32_print.cpp 
+	  
+HEADERS += \
+	$$SOURCE_DIR/core/fxge/win32/cpsoutput.h \
+      $$SOURCE_DIR/core/fxge/win32/dwrite_int.h \
+      $$SOURCE_DIR/core/fxge/win32/cfx_psrenderer.h 
+}
\ No newline at end of file
diff -ENwbur "a/qtpdfium/src/mydiff" ./mydiff
--- "b/qtpdfium/src/mydiff"	1970-01-01 07:00:00.000000000 +0700
+++ ./mydiff	2017-02-12 16:30:54.913551400 +0700
@@ -0,0 +1,62 @@
+diff -ENwbur "a/qtpdfium/src/3rdparty/fxcrt.pri" ./3rdparty/fxcrt.pri
+--- "b/qtpdfium/src/3rdparty/fxcrt.pri"	2017-02-12 12:35:02.326423100 +0700
++++ ./3rdparty/fxcrt.pri	2017-02-12 14:57:38.163318700 +0700
+@@ -2,7 +2,7 @@
+ SOURCE_DIR = $$PWD/pdfium
+ 
+ PRIVATE_HEADERS += \
+-$$SOURCE_DIR/core/fxcrt/fxcrt_qt.h \
++#$$SOURCE_DIR/core/fxcrt/fxcrt_qt.h \
+ $$SOURCE_DIR/core/fxcrt/cfx_maybe_owned.h \
+ $$SOURCE_DIR/core/fxcrt/cfx_observable.h \
+ $$SOURCE_DIR/core/fxcrt/cfx_retain_ptr.h \
+@@ -28,7 +28,7 @@
+ $$SOURCE_DIR/core/fxcrt/xml_int.h
+ 
+ SOURCES += \
+-$$SOURCE_DIR/core/fxcrt/fxcrt_qt.cpp \
++#$$SOURCE_DIR/core/fxcrt/fxcrt_qt.cpp \
+ $$SOURCE_DIR/core/fxcrt/fx_basic_array.cpp \
+ $$SOURCE_DIR/core/fxcrt/fx_basic_bstring.cpp \
+ $$SOURCE_DIR/core/fxcrt/fx_basic_buffer.cpp \
+diff -ENwbur "a/qtpdfium/src/3rdparty/fxge.pri" ./3rdparty/fxge.pri
+--- "b/qtpdfium/src/3rdparty/fxge.pri"	2017-02-12 12:35:02.373223200 +0700
++++ ./3rdparty/fxge.pri	2017-02-12 16:21:39.637575100 +0700
+@@ -42,7 +42,6 @@
+ $$SOURCE_DIR/core/fxge/android/cfpf_skiafont.cpp \
+ $$SOURCE_DIR/core/fxge/android/cfpf_skiafontmgr.cpp \
+ $$SOURCE_DIR/core/fxge/android/cfx_androidfontinfo.cpp \
+-# $$SOURCE_DIR/core/fxge/android/fx_android_imp.cpp \
+ $$SOURCE_DIR/core/fxge/dib/fx_dib_composite.cpp \
+ $$SOURCE_DIR/core/fxge/dib/fx_dib_convert.cpp \
+ $$SOURCE_DIR/core/fxge/dib/fx_dib_engine.cpp \
+@@ -83,8 +82,27 @@
+ $$SOURCE_DIR/core/fxge/ge/fx_ge_fontmap.cpp \
+ $$SOURCE_DIR/core/fxge/ge/fx_ge_linux.cpp \
+ $$SOURCE_DIR/core/fxge/ge/fx_ge_text.cpp \
+-$$SOURCE_DIR/core/fxge/ge/fx_ge_qt.cpp \
++#$$SOURCE_DIR/core/fxge/ge/fx_ge_qt.cpp \
+ $$SOURCE_DIR/core/fxge/agg/fx_agg_driver.cpp \
+ $$SOURCE_DIR/core/fxge/ifx_renderdevicedriver.cpp
+ 
++android*{
++SOURCES += \
++	$$SOURCE_DIR/core/fxge/android/fx_android_imp.cpp 
++}
+ 
++win32{
++SOURCES += \
++	$$SOURCE_DIR/core/fxge/win32/cfx_psrenderer.cpp \
++      $$SOURCE_DIR/core/fxge/win32/cpsoutput.cpp \
++      $$SOURCE_DIR/core/fxge/win32/fx_win32_device.cpp \
++      $$SOURCE_DIR/core/fxge/win32/fx_win32_dib.cpp \
++      $$SOURCE_DIR/core/fxge/win32/fx_win32_dwrite.cpp \
++      $$SOURCE_DIR/core/fxge/win32/fx_win32_gdipext.cpp \
++      $$SOURCE_DIR/core/fxge/win32/fx_win32_print.cpp 
++	  
++HEADERS += \
++	$$SOURCE_DIR/core/fxge/win32/cpsoutput.h \
++      $$SOURCE_DIR/core/fxge/win32/dwrite_int.h \
++      $$SOURCE_DIR/core/fxge/win32/cfx_psrenderer.h 
++}
+\ No newline at end of file
diff -ENwbur "a/qtpdfium/src/pdfium/pdfium.pro" ./pdfium/pdfium.pro
--- "b/qtpdfium/src/pdfium/pdfium.pro"	2017-02-12 12:35:02.404423200 +0700
+++ ./pdfium/pdfium.pro	2017-02-12 15:15:31.814807500 +0700
@@ -13,6 +13,9 @@
 CONFIG += warn_on strict_flags c++11
 load(qt_module)
 
+win32{
+ LIBS+= advapi32.lib
+}
 #QMAKE_DOCS = $$PWD/doc/qtpdfium.qdocconf
 include($$PWD/../3rdparty/pdfium.pri)
 
 

Do you have any suggestion to make passing the testcases? On android my build also was working fine using above patch,
but with untested testcase and my sample android app can open some pdf files same as on windows one.
Thanks

Visual C++ 14 can no longer build since upgrade of pdfium

Hi

It looks like since the upgrade of the bundled pdfium version VC++ is no longer able to build QtPdfium.

Here is the compilation command :

        cl -c -FIQtPdfiumDepends -YuQtPdfiumDepends -Fp.pch\release\Qt5Pdfium_pch.pch -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -D_HAS_EXCEPTIONS=0 -GR -DUNICODE -DWIN32 -D__QT__ -DOPJ_STATIC -DPNG_PREFIX -DPNG_USE_READ_MACROS -DQT_NO_VERSION_TAGGING -DQT_BUILD_PDFIUM_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DFT2_BUILD_LIBRARY -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -D_WINDLL -IC:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\pdfium -I. -I..\..\include -I..\..\include\QtPdfium -IC:/Users/snoopy/Documents/pdfium-test/qtpdfium/build32/include/QtPdfium/5.5.0 -IC:/Users/snoopy/Documents/pdfium-test/qtpdfium/build32/include/QtPdfium/5.5.0/QtPdfium -Itmp -IC:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium -IC:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium\third_party\freetype\include -IC:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium\third_party\freetype\include\freetype -IC:\Qt\5.7\msvc2015\include\QtCore\5.7.1 -IC:\Qt\5.7\msvc2015\include\QtCore\5.7.1\QtCore -IC:\Qt\5.7\msvc2015\include -IC:\Qt\5.7\msvc2015\include\QtGui -IC:\Qt\5.7\msvc2015\include\QtANGLE -IC:\Qt\5.7\msvc2015\include\QtCore -I.moc\release -IC:/utils/my_sql/my_sql/include -IC:/utils/postgresql/pgsql/include -IC:\Qt\5.7\msvc2015\mkspecs\win32-msvc2015 -Fo.obj\release\ @C:\Users\snoopy\AppData\Local\Temp\nm8758.tmp
cba_annotiterator.cpp

And there are then a lot of various errors. Thanks to VC++, the error messages are in french… So I will translate some of them

C:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium\core/fxcrt/fx
_memory.h(29): error C2065: '__noinline__' : undefined identifier
C:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium\core/fxcrt/fx
_memory.h(29): error C4430: missing type specification - int is used by default. Notice: C++ does not use int by default.
C:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium\core/fxcrt/fx
_memory.h(29): error C2448: '__attribute__' : function style initializer seems to be a function declaration
C:\Users\snoopy\Documents\pdfium-test\qtpdfium\src\3rdparty\pdfium\core/fxcrt/fx
_memory.h(43): error C3861: 'FX_OutOfMemoryTerminate' : missing identifier

And so on and so on…
I'll try to find out what is missing here, but I would be happy if you have any hint to help me find out the breaking stuff…

Thanks

Problem compile with QT 5.12.0 Mingw 32 Windows 10

Hello,

I tried to compile the library using QT 5.12.0 with Mingw32 compiler I followed this steps

1 - I open the qtpdfium.pro in release mode and I downloaded the PDFIUM third-party library and add it's content to the folder

2 - I compiled and I got this error
so what the problem I did to not compile so I can fix it?

D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fsdk_actionhandler.cpp:425: error: 'class CPDF_Dest' has no member named 'GetObjectW'; did you mean 'GetObject'? const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:447: error: 'g_pdfium_print_postscript_level' was not declared in this scope g_pdfium_print_postscript_level = postscript_level; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fsdk_actionhandler.cpp:425: error: 'class CPDF_Dest' has no member named 'GetObjectW'; did you mean 'GetObject'? const CPDF_Array* pMyArray = ToArray(MyDest.GetObject()); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: no matching function for call to 'MakeUnique<<expression error> >(HDC__*&)' pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: template argument 1 is invalid pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: template argument 1 is invalid pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: template argument 1 is invalid pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:688: error: 'CFX_WindowsDevice' was not declared in this scope CFX_WindowsDevice WinDC(dc); ^~~~~~~~~~~~~~~~~ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:689: error: 'WinDC' was not declared in this scope if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { ^~~~~ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:447: error: 'g_pdfium_print_postscript_level' was not declared in this scope g_pdfium_print_postscript_level = postscript_level; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: 'CFX_WindowsDevice' was not declared in this scope pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^~~~~~~~~~~~~~~~~ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: no matching function for call to 'MakeUnique<<expression error> >(HDC__*&)' pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: template argument 1 is invalid pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: template argument 1 is invalid pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:681: error: template argument 1 is invalid pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc); ^ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:688: error: 'CFX_WindowsDevice' was not declared in this scope CFX_WindowsDevice WinDC(dc); ^~~~~~~~~~~~~~~~~ D:\build\qtpdfium-master\src\3rdparty\pdfium\fpdfsdk\fpdfview.cpp:689: error: 'WinDC' was not declared in this scope if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { ^~~~~

Add text extraction API

Hi

This project is great for rendering so far, but it would be really nice to be able to access some text extraction API. For instance, being able to extract the text at a specific location, or every text element of a page.

NB: if I find enough spare time, I'll try to work on this, but I can't promise anything

Transparency in QPdfiumPage::image()

Hi,

Right now the QImage returned by QPdfiumPage::image() is filled with a fully opaque white color.
Changing line number 90 in file qpdfiumpage.cpp fom:

image.fill(0xFFFFFFFF);

to:

image.fill(Qt::transparent);

would fix the transparency problem. What do you think?

Kind regards,
Ion

doesn't work on ios

Hi, thank for this great module.
I created a test app, and it works smoothly on my Mac(osx 10.12.1). But it cannot render the image on my iPad(iOS 10.0.1). Here are some log outputs:

pageCount: 10
pdfium_ valid: true
pageIndex = 1
img.isNull() = true
img.width() = 0
img.height() = 0

Any suggestion? Thank you.

By the way, the global PdfiumGlobal object failed to initialize the FPDF library. So, I commented out that line code. Instead, a temporary fix, using a global scope pointer to hold it, skiped that issue in my test app.

Git clone fails - submodule references an invalid commit

Hi

A git clone --recursive now fails, with the submodule referencing a wrong commit.

snoopy@peanuts2:~/projects$ git clone --recursive https://github.com/paulovap/qtpdfium                                                                                                                                                                                         
Cloning into 'qtpdfium'...                                                                                                                                                                                                                                                     
remote: Counting objects: 270, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 270 (delta 35), reused 0 (delta 0), pack-reused 191
Receiving objects: 100% (270/270), 892.54 KiB | 1.03 MiB/s, done.
Resolving deltas: 100% (111/111), done.
Submodule 'src/3rdparty/pdfium' (https://github.com/paulovap/pdfium.git) registered for path 'src/3rdparty/pdfium'
Cloning into '/home/snoopy/projects/qtpdfium/src/3rdparty/pdfium'...
remote: Counting objects: 75929, done.        
remote: Total 75929 (delta 0), reused 0 (delta 0), pack-reused 75928        
Receiving objects: 100% (75929/75929), 73.03 MiB | 1.42 MiB/s, done.
Resolving deltas: 100% (59981/59981), done.
error: no such remote ref 346afae7e9d4ee808c1954cf911a960be3095302
Fetched in submodule path 'src/3rdparty/pdfium', but it did not contain 346afae7e9d4ee808c1954cf911a960be3095302. Direct fetching of that commit failed.

Did you by mistake reference a local commit ? Or did the upstream drop a commit ?

QImage QPdfiumPage::image() format

Hi,

I was wandering if it wouldn't be a good idea to change the format of the QImage returned by QPdfiumPage::image() to QImage::Format_ARGB32_Premultiplied or QImage::Format_ARGB32.

This way the loop that swaps the pixel values would no longer be necessary. What do you think?

Kind regards,
Ion

Visual C++ 14 can no longer build since upgrade of pdfium

The commit b69b17b does not compile on my Windows 8.1 machine, with MSVC 14 (it is the only commit I have tested).

Seems to be the same issue that Pinaraf had last year:

fx_memory.h:
C2065: noinline undeclared identifier
C4430: missing type specifier
C3861: FX_OutOfMemoryTerminate identifier not found
C2448: attribute function-style initializer appears to be a specific function definition

fx_stream.h:
C1083: Cannot open include file: 'dirent.h'. No such file or directory

I have opened the project file in QtCreator and tried to run the 'cpp' target.

Build issues on Windows and Linux

Hi,

First of all thanks for your work on QtPdfium.
I tried it on Linux and Windows and I have encountered the following issues:

  1. On Linux Ubuntu 16.04 64-bit with Qt version 5.5.1 and gcc version 5.4.0 the library itself can be built out of the box but when trying to use it there's a compile error message:

/src/pdfium/qpdfium.h:52:36: error: ‘>>’ should be ‘> >’ within a nested template argument list
QVector<QWeakPointer> m_pages;

In order to fix it, you need to change the incriminated line to:
QVector<QWeakPointer > m_pages;

  1. On Windows 10 64-bit with Qt 5.6.1 and MinGW compiler (gcc version 5.4.0, built by MSYS2 project) the compilation fails with the error message bellow.

Could you, please, add support for the MinGW compiler?

Thanks in advance for your help and best regards,
Ion

make[3]: Entering directory '/c/qtiplot/3rdparty/qtpdfium/src/pdfium'
g++ -c -pipe -fno-keep-inline-dllexport -march=nocona -mtune=core2 -Wa,-mbig-obj -O2 -std=c++1z -Wall -Wextra -fno-exceptions -frtti -DUNICODE -D__QT__ -DOPJ_STATIC -DPNG_PREFIX -DPNG_USE_READ_MACROS -DQT_NO_VERSION_TAGGING -DQT_BUILD_PDFIUM_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DFT2_BUILD_LIBRARY -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -IC:/msys64/mingw64/include/dbus-1.0 -IC:/msys64/mingw64/lib/dbus-1.0/include -IC:/msys64/mingw64/include/libxml2 -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/mariadb -I../../include -I../../include/QtPdfium -IC:/qtiplot/3rdparty/qtpdfium/include/QtPdfium/5.5.0 -IC:/qtiplot/3rdparty/qtpdfium/include/QtPdfium/5.5.0/QtPdfium -Itmp -I../3rdparty/pdfium -I../3rdparty/pdfium/third_party/freetype/include -I../3rdparty/pdfium/third_party/freetype/include/freetype -IC:/msys64/mingw64/include/QtCore/5.6.1 -IC:/msys64/mingw64/include/QtCore/5.6.1/QtCore -IC:/msys64/mingw64/include/QtGui -IC:/msys64/mingw64/include/QtCore -I.moc/release -IC:/msys64/mingw64/share/qt5/mkspecs/win32-g++ -o .obj/release/fpdfview.o ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp
In file included from ../3rdparty/pdfium/core/fpdfapi/parser/cpdf_indirect_object_holder.h:15:0,
from ../3rdparty/pdfium/core/fpdfapi/parser/cpdf_array.h:16,
from ../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:15:
../3rdparty/pdfium/core/fpdfapi/parser/cpdf_object.h:117:34: warning: unused parameter 'src' [-Wunused-parameter]
CPDF_Object(const CPDF_Object& src) {}
^
../3rdparty/pdfium/core/fpdfapi/parser/cpdf_object.h:117:34: warning: unused parameter 'src' [-Wunused-parameter]
../3rdparty/pdfium/fpdfsdk/fpdfview.cpp: In function 'FPDF_BOOL FPDF_SetPrintPostscriptLevel(int)':
../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:447:3: error: 'g_pdfium_print_postscript_level' was not declared in this scope
g_pdfium_print_postscript_level = postscript_level;
^
../3rdparty/pdfium/fpdfsdk/fpdfview.cpp: In function 'void FPDF_RenderPage(HDC, FPDF_PAGE, int, int, int, int, int, int)':
../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:681:46: error: 'CFX_WindowsDevice' was not declared in this scope
pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc);
^
../3rdparty/pdfium/fpdfsdk/fpdfview.cpp:681:67: error: no matching function for call to 'MakeUnique(HDC__*&)'
pContext->m_pDevice = pdfium::MakeUnique<CFX_WindowsDevice>(dc);

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.