PDA

View Full Version : Qt, pdf files and help functions



mtnbiker66
11th August 2012, 17:59
Good afternoon --

My client and I were talking last night about adding a help feature to his application. I was thinking using the tool tips for the widgets but he said that his PDF help document that he already has is too extensive to retype back in so what he wants is a feature similar to the F1 feature within Qt Creator so that when he hovers over a widget, clicks help, it would bring up the PDF to the exact location in the document for that widget. Doing some cursory searching I see there's various ways to display a PDF so my initial questions are:

1) Is this even possible, to jumpt to a location like this?
2) Is there a preferred method of displaying a PDF? I see poppler and ghostscript quite a bit popping up.
3) I've considered dropping the PDF into my database and then reading it back out and displaying it but that's and idea.

I made the mistake of showing how Qt Creator handled the help/F1 within the code editor, and he'd like something similar if possible. Never show a client what's possible, especially when they're a relative :)



Kodi

d_stranz
11th August 2012, 19:38
Never mix business and relatives. Hope you're learning a lesson here.

Is the PDF document bookmarked? If so, do either Poppler or Ghostscript have an API that let you navigate to a bookmark?

Another option: Convert the PDF to HTML and use QtWebKit to display it. This PDF to HTML tool looks pretty impressive: PDFToHTML (http://pdftohtml.sourceforge.net/) There is also this tool (http://www.dbai.tuwien.ac.at/staff/hassan/pdfxtk.html) which might let you turn it into a Qt Assistant document.

After further research, I see that PDFToHTML is now part of Poppler. This looks interesting enough that I might try it out.

mtnbiker66
12th August 2012, 17:55
I got put in a corner with the relative and a large dollar offer if I created the app; sometimes you take one for the team :)

I don't know if the PDF is bookmarked -- I'll need to get a copy of it to find out -- but I like the idea of converting it to HTML or maybe the extraction toolkit. Looks like time to experiment -- thanks for the tips!


Kodi



I'm liking QHelpEngine API as an option, but I'd have to deconstruct the PDF documentation...

d_stranz
13th August 2012, 01:31
To satisfy my own curiosity, I downloaded the Poppler source and managed to build it (in Windows, using Visual Studio) after a bit of work (had to download freetype, and it requires CMake to build the VS projects).

It includes a Qt4 extension that allow you to display and navigate through a PDF file in a Qt app; there is a demo that illustrates this. The extension is documented here (http://people.freedesktop.org/~aacid/docs/qt4/).

The major issue of concern is that poppler is GPL, not LGPL, so if your relative is intending to sell the software you write or use it commercially, you will have to get a commercial license. The company Glyph and Gog (www.glyphandcog.com), which owns the rights to the Xpdf code that is used in poppler, licenses a PDF viewer widget for Qt, XpdfWidget (http://www.glyphandcog.com/XpdfWidgetQt.html). No idea what it costs, but I will be looking into it.

mtnbiker66
13th August 2012, 12:59
I need to be able to compile it on Windows and Mac -- I did notice it looks a little tricky and I didn't get a chance to play with it this weekend (a very active 14 month old rules the roost)...

The app I'm writing is meant to be a "helper" tool for a simulation program which currently accepts a flat-file for data entry; I'm creating a database of the data he uses so that he can create his flat-file faster so he can run more simulations. There is the potential for licensing to some of his clients who currently license his app, so I'll have to bring that up to him -- thanks for the catch of that; totally slipped by me!

I found this thread, too: http://www.qtcentre.org/threads/48870-how-to-read-and-write-pdf


Kodi

d_stranz
13th August 2012, 18:02
I found this thread, too: http://www.qtcentre.org/threads/4887...-and-write-pdf


Well, ActiveX isn't going to work so well on the Mac OS, I don't think. Does the Acrobat Reader COM API have sufficient flexibility that you can direct it to a specific page in the document? If so, that would be an easy implementation on Windows. Wrap the Ax stuff in a controller class that hides the details from your app so you could potentially replace it if something more portable is required. Your work would then boil down to creating a cross-index between help topic and PDF page number so you could open the document to the appropriate page. I would make the PDF controller class a member of your MainWindow class so you could keep the document open and simply go to a different page once it is initially opened. I don't know if Reader is smart enough not to open the same document twice through the Ax interface. You'd also have to make sure the Ax API could tell you if the user manually closed the document so you could free up the pointer.

mtnbiker66
13th August 2012, 18:31
Yea, I knew it wouldn't work on a Mac but it's an option. You've definitely nailed what I was thinking I wanted to do -- now if I can just find the skills to make that happen :) I'm going to research this option more tonight -- during a lunch break at my day job just doesn't cut it but I can let you know...I've got a e-mail off the folks at Glyph and Cog about licensing and I've also been playing with converting the PDF to HTML, but that generated a lot of jpg files that I wasn't expecting, so I'm not sure how that will play out.

Thanks for your suggestions!



Kodi


yet another possibility: http://qt-apps.org/content/show.php?content=149637

mtnbiker66
14th August 2012, 02:50
Somewhat over thinking this a bit in some w-- using QDesktopServices::openUrl(QUrl()) opens the PDF to whatever the default application is for the OS -- it however seems to lack the ability to jump to a page in the document when the "#page=" option is added to the URL. That I understand is what's desired --

peterlee
31st March 2016, 10:50
Hi, mtnbiker66.
Thanks for your nice sharing. As you see, there are many free conversion tools online. But I don't suggest you to use them to do with your conversion work. Because I always believe that the free tools online do not have so many professional functions as the paid ones. And it is said that some of them might contain some virus. Check some free trials of the paid professional conversion tools to convert pdf to jpg (http://www.pqscan.com/convert-pdf/to-jpg.html) using C#.NET first before you make your final decision if possible. I also suggest you choose one whose way of processing is simple and fast. It can save a laot of time for you. Remember to do your conversion work according to its tutorial page about PDF to image conversion (http://www.pqscan.com/pdf-to-image/). I hope you success. Good luck.



Best regards,
Pan

d_stranz
31st March 2016, 21:28
I would guess that since the original post is over 3 1/2 years old, the OP has finished this project and has forgotten about it. Why did you waste your time commenting?