Solved using QAxWidget to open pdf, printing is not working
-
@philxxx609 hi, I am using Adobe PDF Reader ActiveX Control in Qt.
I run your code, but it didn't display the pdf file. I don't know what is wrong.
It just display a gray background.
thank for your help. -
My Qt version is 5.15.2
qDebug() << pdf->control(); // return the right UUID . qDebug() << pdf->dynamicCall("LoadFile(QString)", "E:/signed.pdf").toBool(); // return true
-
@hank17_0
I think you may have tried this, and I admit that you say the call returns true so it may not be a problem, but I wouldn't have passed a path with forward slashes toLoadFile
, I would have passed a Windows path with backslashes.P.S.
Otherwise, just maybe it has read the document but isn't showing a page? For all I know maybe you needSetCurrentPage(1)
. Or what aboutSetShowToolbar(true)
or theSetPageMode("bookmarks")
just to see whether either of these appear? -
Hi, totally agreeing with @JonB, forward slashes can spell trouble.
Also, maybe that particular pdf has a problem (just guessing) why not try another PDF (from Wikipedia):
qDebug() << pdf->dynamicCall("LoadFile(QString)", "http://tripleboot.org/Pictures/GettysburgAddress.pdf").toBool(); // return true
-
@JonB Thanks for your reply. I will try it.
-
@JonB still the same gray background. I used
pdf->dynamicCall("SetCurrentPage(1)"); pdf->dynamicCall("SetPageMode(\"bookmarks\")");
nothing happened.
I also use
dumpcpp "{CA8A9780-280D-11CF-A24D-444553540000}"
to generate
acropdflib.cpp
andacropdflib.h
file.
But when I use these file in my project, it can't complie.unknown type name '_IAcroAXDocShimEvents'.
-
@hskoglund Hi thank you for your advice. I try another pdf file, but not work.
-
Hmm, COM technology is old, maybe you're compiling/building for 64-bits?
Try 32-bit, it should work better. -
Yes, just to confirm, I built the app both in MSVC2019 32-bit and 64-bit versions. Both version gave the same qDebug() output and no errors.
But the 64-bit version returns only a grey page (same as you got).
The 32-bit version works.P.S: More users have had this problem, eg. https://forum.qt.io/topic/119455/qaxwidget-adobe-pdf-reader-working-with-kit-qt-5-14-1-msvc2017-32-but-not-with-kit-with-qt-5-14-1-msvc2017-64
-
@hskoglund Thanks for your reply. I will try it tomorrow. Very appreciate.
-
@hskoglund Yes, it works. Build with MSVC2019 32-bit works. Thanks for your help.