View Full Version : Portable way to use PDF files for help?

24th February 2011, 11:20
I want my application to open a PDF file. Something like this:

QDesktopServices::openUrl(QUrl("file:///C:/Data/help.pdf", QUrl::TolerantMode));

My problem is when I want to open the file at an specific location which should work like this:

QDesktopServices::openUrl(QUrl("file:///C:/Data/help.pdf#page=23", QUrl::TolerantMode));

However the above line will only work if I type the URL within a browser (safari, firefox, iexplorer...) but not from Qt, neither from rundll.exe

Which one is the best and most portable way? I do not want to look for Acrobat myself for launching a detached process with the right parameters

thanks in advance!

27th February 2011, 10:08
openURL() is an equivalent to double-clicking the file in a file explorer. There you can't order the OS to pass additional parameters to the file handler and neither can you here. If you wish to open the file in a particular page, you have to bind yourself to a specific pdf browser and call it directly via things like QProcess passing it appropriate parameters. Or you can use libpoppler to display the pdf directly in your own app.