archie3d / qpdf Goto Github PK
View Code? Open in Web Editor NEWPDF viewer widget for Qt
License: GNU Lesser General Public License v2.1
PDF viewer widget for Qt
License: GNU Lesser General Public License v2.1
Original working code was based on Qt 5.4.
When compiled with Qt 5.5 the PDF document rendering with pdf.js fails. An update of pdf.js library may require.
after build the lib successfully, when i execute the "./pdfwiver", the follows error message will display in the terminal:
Starting ../build-qpdf-Qt5_12_8-Debug/pdfviewer/pdfviewer ...
js: #thumbs is undefined.
js: #thumbs is undefined.
js: #thumbs_label is undefined.
js: #thumbs_label is undefined.
js: #document_outline is undefined.
js: #document_outline is undefined.
js: #document_outline_label is undefined.
js: #document_outline_label is undefined.
js: #attachments is undefined.
js: #attachments is undefined.
js: #attachments_label is undefined.
js: #attachments_label is undefined.
js: #find_input is undefined.
js: #find_input is undefined.
js: #find_previous is undefined.
js: #find_previous is undefined.
js: #find_previous_label is undefined.
js: #find_previous_label is undefined.
js: #find_next is undefined.
js: #find_next is undefined.
js: #find_next_label is undefined.
js: #find_next_label is undefined.
js: #find_highlight is undefined.
js: #find_highlight is undefined.
js: #find_match_case_label is undefined.
js: #find_match_case_label is undefined.
js: #presentation_mode is undefined.
js: #presentation_mode is undefined.
js: #presentation_mode_label is undefined.
js: #presentation_mode_label is undefined.
js: #open_file is undefined.
js: #open_file is undefined.
js: #open_file_label is undefined.
js: #open_file_label is undefined.
js: #print is undefined.
js: #print is undefined.
js: #print_label is undefined.
js: #print_label is undefined.
js: #download is undefined.
js: #download is undefined.
js: #download_label is undefined.
js: #download_label is undefined.
js: #bookmark is undefined.
js: #bookmark is undefined.
js: #bookmark_label is undefined.
js: #bookmark_label is undefined.
js: #first_page is undefined.
js: #first_page is undefined.
js: #first_page_label is undefined.
js: #first_page_label is undefined.
js: #last_page is undefined.
js: #last_page is undefined.
js: #last_page_label is undefined.
js: #last_page_label is undefined.
js: #page_rotate_cw is undefined.
js: #page_rotate_cw is undefined.
js: #page_rotate_cw_label is undefined.
js: #page_rotate_cw_label is undefined.
js: #page_rotate_ccw is undefined.
js: #page_rotate_ccw is undefined.
js: #page_rotate_ccw_label is undefined.
js: #page_rotate_ccw_label is undefined.
js: #cursor_text_select_tool is undefined.
js: #cursor_text_select_tool is undefined.
js: #cursor_text_select_tool_label is undefined.
js: #cursor_text_select_tool_label is undefined.
js: #cursor_hand_tool is undefined.
js: #cursor_hand_tool is undefined.
js: #cursor_hand_tool_label is undefined.
js: #cursor_hand_tool_label is undefined.
js: #scroll_vertical is undefined.
js: #scroll_vertical is undefined.
js: #scroll_vertical_label is undefined.
js: #scroll_vertical_label is undefined.
js: #scroll_horizontal is undefined.
js: #scroll_horizontal is undefined.
js: #scroll_horizontal_label is undefined.
js: #scroll_horizontal_label is undefined.
js: #scroll_wrapped is undefined.
js: #scroll_wrapped is undefined.
js: #scroll_wrapped_label is undefined.
js: #scroll_wrapped_label is undefined.
js: #spread_none is undefined.
js: #spread_none is undefined.
js: #spread_none_label is undefined.
js: #spread_none_label is undefined.
js: #spread_odd is undefined.
js: #spread_odd is undefined.
js: #spread_odd_label is undefined.
js: #spread_odd_label is undefined.
js: #spread_even is undefined.
js: #spread_even is undefined.
js: #spread_even_label is undefined.
js: #spread_even_label is undefined.
js: #document_properties is undefined.
js: #document_properties is undefined.
js: #document_properties_label is undefined.
js: #document_properties_label is undefined.
js: #toggle_sidebar is undefined.
js: #toggle_sidebar is undefined.
js: #toggle_sidebar_label is undefined.
js: #toggle_sidebar_label is undefined.
js: #findbar is undefined.
js: #findbar is undefined.
js: #findbar_label is undefined.
js: #findbar_label is undefined.
js: #previous is undefined.
js: #previous is undefined.
js: #previous_label is undefined.
js: #previous_label is undefined.
js: #next is undefined.
js: #next is undefined.
js: #next_label is undefined.
js: #next_label is undefined.
js: #page is undefined.
js: #page is undefined.
js: #presentation_mode is undefined.
js: #presentation_mode is undefined.
js: #presentation_mode_label is undefined.
js: #presentation_mode_label is undefined.
js: #open_file is undefined.
js: #open_file is undefined.
js: #open_file_label is undefined.
js: #open_file_label is undefined.
js: #print is undefined.
js: #print is undefined.
js: #print_label is undefined.
js: #print_label is undefined.
js: #download is undefined.
js: #download is undefined.
js: #download_label is undefined.
js: #download_label is undefined.
js: #bookmark is undefined.
js: #bookmark is undefined.
js: #bookmark_label is undefined.
js: #bookmark_label is undefined.
js: #tools is undefined.
js: #tools is undefined.
js: #tools_label is undefined.
js: #tools_label is undefined.
js: #zoom_out is undefined.
js: #zoom_out is undefined.
js: #zoom_out_label is undefined.
js: #zoom_out_label is undefined.
js: #zoom_in is undefined.
js: #zoom_in is undefined.
js: #zoom_in_label is undefined.
js: #zoom_in_label is undefined.
js: #zoom is undefined.
js: #zoom is undefined.
js: #page_scale_auto is undefined.
js: #page_scale_auto is undefined.
js: #page_scale_actual is undefined.
js: #page_scale_actual is undefined.
js: #page_scale_fit is undefined.
js: #page_scale_fit is undefined.
js: #page_scale_width is undefined.
js: #page_scale_width is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #page_scale_percent is undefined.
js: #first_page is undefined.
js: #first_page is undefined.
js: #last_page is undefined.
js: #last_page is undefined.
js: #page_rotate_cw is undefined.
js: #page_rotate_cw is undefined.
js: #page_rotate_ccw is undefined.
js: #page_rotate_ccw is undefined.
js: #error_more_info is undefined.
js: #error_more_info is undefined.
js: #error_less_info is undefined.
js: #error_less_info is undefined.
js: #error_close is undefined.
js: #error_close is undefined.
js: #password_label is undefined.
js: #password_label is undefined.
js: #password_cancel is undefined.
js: #password_cancel is undefined.
js: #password_ok is undefined.
js: #password_ok is undefined.
js: #document_properties_file_name is undefined.
js: #document_properties_file_name is undefined.
js: #document_properties_file_size is undefined.
js: #document_properties_file_size is undefined.
js: #document_properties_title is undefined.
js: #document_properties_title is undefined.
js: #document_properties_author is undefined.
js: #document_properties_author is undefined.
js: #document_properties_subject is undefined.
js: #document_properties_subject is undefined.
js: #document_properties_keywords is undefined.
js: #document_properties_keywords is undefined.
js: #document_properties_creation_date is undefined.
js: #document_properties_creation_date is undefined.
js: #document_properties_modification_date is undefined.
js: #document_properties_modification_date is undefined.
js: #document_properties_creator is undefined.
js: #document_properties_creator is undefined.
js: #document_properties_producer is undefined.
js: #document_properties_producer is undefined.
js: #document_properties_version is undefined.
js: #document_properties_version is undefined.
js: #document_properties_page_count is undefined.
js: #document_properties_page_count is undefined.
js: #document_properties_page_size is undefined.
js: #document_properties_page_size is undefined.
js: #document_properties_close is undefined.
js: #document_properties_close is undefined.
js: #print_progress_message is undefined.
js: #print_progress_message is undefined.
js: #print_progress_percent is undefined.
js: #print_progress_percent is undefined.
js: #print_progress_close is undefined.
js: #print_progress_close is undefined.
js: #of_pages is undefined.
js: #page_scale_percent is undefined.
My question is how to avoid this error message?
Thanks!
Hello, I use qpdf in my application since some months ago. Everything worked fine but I'd like to switch my application from x86 to x64.
If I build the qpdf library with Qt_5_12_7_MSVC2017_64bit-Debug kit:
-> My application works fine in debug mode; I'm able to load pdf file
-> My application doesn't work in release mode; I get this error: QWidget: Must construct a QApplication before a QWidget
If I build the qpdf library with Qt_5_12_7_MSVC2017_64bit-Realease kit:
-> My application doesn't work in debug mode; I'm not able to load pdf and I get this error:
Resource :/pdfview/pdf.js not found or is empty
Resource :/pdfview/viewer.js not found or is empty
Uncaught ReferenceError: qpdf_Initialize is not defined
-> My application doesn't work in release mode; I'm not able to load pdf and I get this error:
Resource :/pdfview/pdf.js not found or is empty
Resource :/pdfview/viewer.js not found or is empty
Uncaught ReferenceError: qpdf_Initialize is not defined
As you can see it works in debug mode when the library is built in debug mode too.
But I'd like to build my application in release mode.
Do you have any idea from where the problem could come from? Thanks a lot for your help.
Hi,
I would like to know under which license do you release this small piece of code, please?
Thanks,
Arnaud
Project ERROR: Unknown module(s) in QT: webengine webenginecore webenginewidgets webchannel
I am using ubuntu 20.04 and installed webenginecore and corresponding libraries
please add support for linux.
i added this lib in my app for linux. it builds and runs fine.
but when i packaged it and install it in system it does not found by my app.
because there is no path to put it in linux syatem .
and it is conflicts with another library named same qpdf.
i think if you change the name to be different library.
here is my app GITHUB
i have some feature request.
i hope this feature is relevant to qpdf and get this in next release.
How can i run your viewer example?
I open the .pro on qt creatorn and i build the project with this error:
"cannot find -lqpdf"
pdfjsbridge.cpp(133): error C2039: “setWebChannel”: 不是“QWebEnginePage”的成员
When a parallel build is done (e.g. make -j 10) the build will fail because pdfviewer will try to use -lqpdf before that is built.
I used a slightly modified version of the pdfviewer example with a red background so I can easily see the exact dimension of the QPdfWidget instance, otherwise it is the exact code from the repository.
Initially a PDF is shown
on a device with touchscreen, and everything compiled with Qt 5.9.1. Then I used a pinch gesture to shrink the PDF contents. However the area of the rendering shrinked with it I would have expected it to still use the full height of the QPdfWidget, showing more than the initial half page.
If I then use a scroll gesture it depends on the location of the gesture inside the QPdfWidget which behavior I get:
I build on qtcreator and vs 2019.
When I want to use of qpdf.lib like example, I get this error on build (debugx64):
error C2491: 'QPdfWidget::staticMetaObject': definition of dllimport static data member not allowed
i am in linux. qt5.10.1.
i tried to make a sample project with qpdf lib with designer(not with code)
made new ui/cpp/h .added a layout and added this lines in conostrector .
`
m_pPdfWidget = new QPdfWidget();
ui->layout->addWidget(m_pPdfWidget);
QString filePath = QString::fromLatin1("/home/shaber/Desktop/c.pdf");
m_pPdfWidget->loadFile(filePath);
`
pdf widget shows just fine.but the given pdf is not showing.
opening pdf with the folder icon within the pdfwidget working fine.
here is the application output.
[0509/175601.963406:WARNING:stack_trace_posix.cc(648)] Failed to open file: /home/shaber/#272223 (deleted) Error: No such file or directory qt5ct: using qt5ct plugin QMetaObject::connectSlotsByName: No matching signal for on_open_clicked() js: The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType. js: Failed to load file:///home/shaber/Desktop/c.pdf: Cross origin requests are only supported for protocol schemes: http, data, chrome, https. js: Uncaught TypeError: Cannot read property 'onProgressiveData' of undefined js: Uncaught TypeError: Cannot read property 'reject' of undefined
i think i need to add the code in main.cpp that you added in your one .but i don't want any command line support.
so how i solve this problem.
please help me.
This works well.
But what if i dot want to use bookmark by pdf.js and rather i want list of bookmark from pdf.js and want to show in qtreeview. How can that be possible?
i am trying to get the pdf file properties . as the properties window is showing with out loading the file so properties window only a blank window . also the i am not getting the file destination with the "getDestinations" function .
is there a separate function to get know the file is loaded ?? if there i need to check if the file is loaded the request for the properties and destination.
` void corepdf::openPdfFile(const QString path)
{
QVBoxLayout * mainLayout = new QVBoxLayout();
PdfWidget = new QPdfWidget();
connect(PdfWidget, &QPdfWidget::initialized, [this,path]() {
PdfWidget->setToolbarVisible(true);
PdfWidget->showDocumentProperties();
qDebug() << PdfWidget->getDestinations();
QFile f(path);
if (f.open(QIODevice::ReadOnly)) {
QByteArray data = f.readAll();
PdfWidget->loadData(data);
f.close();
}
});
mainLayout->setContentsMargins(0,0,0,0);
mainLayout->addWidget(PdfWidget);
setLayout(mainLayout);
}`
here is the output
thanks
Please Add the ability to fill out forms in pdf!
i am requesting for this features.
i am very much fond of your work and thanks for updating the pdf.js to v2.
Can you update pdf.js ?
Thanks
please update the pdf.js to latest one .
as it has many bug fixes
Thanks your good job. I'm learning your code, but I don't understand what PdfJsBridge::fetchPdfDocumentDestinations and qpdf_FetchDestinations do. It transport data for pdf? Could you explain it ?
QPdfWidget::setToolbarVisible(bool)
does not work after pdf.js update.
I want to use the qpdf as a library of my app .
But qpdf is an app and it come with app and the library.
so i need to add the whole repo and it will come with the app .but it is not convenient to make an app with two front end and with one library.One only need the library to make an app based on the qpdf.
And i want my app in GPL but the license make it impossible to make my app in GPL and library in LGPL.
Also add Linux and windows installation requirements in qmake .i don't know about windows ,here is an example of mac and linux qmake .here is the library libarchive-qt
``
unix {
isEmpty(PREFIX) {
PREFIX = /usr
}
INSTALLS += target includes data
CONFIG += create_pc no_install_prl link_pkgconfig
contains(DEFINES, LIB64): target.path = $$INSTALL_PREFIX/lib64
else: target.path = $$INSTALL_PREFIX/lib
target.path = $$PREFIX/lib/
includes.files = libarchiveqt.h
includes.path = $$PREFIX/include/
data.path = $$PREFIX/share/lib$$TARGET/
data.files = Changelog README
QMAKE_PKGCONFIG_NAME = libarchive-qt
QMAKE_PKGCONFIG_DESCRIPTION = A Qt based archiving solution with libarchive backend
QMAKE_PKGCONFIG_PREFIX = $$INSTALL_PREFIX
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$includes.path
QMAKE_PKGCONFIG_VERSION = $$VERSION
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
}
macx {
INCLUDEPATH += /usr/local/opt/libarchive/include /usr/local/opt/xz/include
QMAKE_LFLAGS += -L/usr/local/opt/libarchive/lib -L/usr/local/opt/xz/lib
}
``
so i am suggesting that make an option in qmake to build the library with the app or make a separate repo for only the library . it will be best .
Hello,
is it possible to display PDFs which has inside them a video? Y see the video in the PDF file, but the play button does not work. In Abode Reader works.
Thanks you very much.
I found that QPdfWidget::renderPdf() call to unknow javascript function "showPDFFile" then the application will show a default file ?
Which method i can use to show a specific PDF file ?
Tks.
please update, thank you very much!
I've had success using it within QT Creator, both in DEBUG and RELEASE.
But when trying to DEPLOY, that is, using it outside the QT environment, my program run ok, but when it calls to show the PDF, the program gives a CRASH.
Where should the RESOURCES be placed, along with the .EXE or in another directory?
how can i close the opened pdf??
in my app i added the qdfwidget .
when i close the qdfwidget , it crashes the whole app .
i think i need to close the qdfwidget properly.
i tried
` void corepdf::eclose(){
QPdfWidget cpdf = this->findChild<QPdfWidget>("QPdfWidget");
cpdf->close();
}
`
.but qdfwidget not closing .
how can i close qdfwidget properly??
I tried to load a pdf file and I'm running into this error:
js: Uncaught (in promise) TypeError: Cannot read property 'classList' of null
[1:2:0126/013732.141117:ERROR:channel.cc(507)] Invalid message size: 378616088
Your pdfviewer stays completely grey. It is displayed normally into Firefox 58.0.
when open some big pdf,the program crash.
When i compile the project via the qt creator using debug mode everything works fine.
But when i change to release i get the following error:
js: Uncaught ReferenceError: qpdf_Initialize is not defined
Any idea why that might happen. Thanks in advance.
the problem is i will include this corepdf in my app CoreBox.
for this i need one qmake for my main app that could include all the cpp and header file including corepad's library.
so my consernt is that if i include the library in the same qmake , is there any problem??
like this
`
TEMPLATE = app
CONFIG += c++11
QT += widgets
webengine
webenginecore
webenginewidgets
webchannel
HEADERS += corepdf.h
qpdflib/pdfjsbridge.h
qpdflib/qpdf.h
qpdflib/qpdfwidget.h \
SOURCES +=
corepdf.cpp
main.cpp
qpdflib/pdfjsbridge.cpp
qpdflib/qpdfwidget.cpp \
RESOURCES +=
qpdflib/pdfview.qrc
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.