Open PDF file in Qt - qt

I want to read a .PDF file in Qt. I placed my .PDF file in the resource(qrc) folder.
How can i read the PDF file from there? I want to load a PDF file on the click of a button.

Read your pdf file via QFile, resource access is done by prepending the path in the resource with a ":".
Qt does not natively support displaying PDF documents (it can export them using QPrinter though). You can do it through third-party libraries such as Poppler, see this Qt Quarterly edition on how to do it.
FWIW the resource access information is the docs, and the PDF stuff I got off Google in 30 seconds. I expect a bit more research effort for someone with 7K+ rep points.

Related

Opening/Editing Qt Resource File (.rcc)

I want to translate a program; but its language files (.qm) are in a .rcc file.
The program is not mine, so I haven't got any .qrc file.
Before asking this question, I have searched this site about this issue; but I don't attain anything.
Is there any way to extract/decompile it?
You can take my tool RccExtended - it based on the official Qt resource compiler with additional function to decompile binary resources.
Usage example:
cd \Path\To\MyQtResources\
rcc --reverse
Decompiler will unpack all .rcc files in the current directory, generate .qrc files and make.bat file to compile resources back to the binary format.
There isn't a supported way to decompile it as far as I'm aware, but it's a binary file format that can be read and handled. There's a nodejs example of how to read the file and extract PNGs on github: https://github.com/gcochard/png-extractor. It may be possible to extend that method out for the .qm files.
However there's other issues with attempting to add more translations to a Qt application without having the code, depending on the language you're attempting to add, how the developer has exposed the other languages etc.

How to intergrate PDF viewer(display) in the GTK+ interface

Am working on the project in which am required to fetch files from the server and to display them on the client post.All of this is to be done in the UNIX environment where I used C language for coding client and server and GTK+ for the interface which will display files in the PDF format.
My problem is I do not know how can I intergrate a PDF viewer in such interface.
As the final results I would like when I select the file and click GTKbutton it displays the file in a PDF format in that intergrated viewer.
Check out the EvView and EvDocument libraries. They are not too well documented but it's a GTK widget for displaying PDFs and other documents.

Creating Documentation Using QtHelp Module

Qt provides two kinds of help files: Qt Compressed Help (.qch) and Qt Help Collection (.qhc).
The first one actually contains compressed help data (html pages, images etc). The second one contains references to different compressed help files.
Both Qt Assistant and QHelpEngine are using collection files to display help. So I need at least two files to provide documentation for my application: .qch and .qhc.
I want to have a single help file to be used by Qt Help API (e.g. like a .chm help file in Windows).
Is it possible?
I don't think it is possible to create a chm file using QtHelp module since chm files are Microsoft specific and not an independent format.
But all the chm files are opened by the hh.exe application that belongs to HTML Help workshop. I have accessed chm files for opening a specified html page using hh application.
You can have a look over here in my answer.
If there are command line options provided by Microsoft to compile chm files either by hh or through HTML Help workshop command line (if any), you can do that by running the command in QProcess. You have to probe more into that.
Or you can create chm files manually using HTML Help workshop and integrate the chm files into the application.
Hope that helps in giving you a start.
I have not tried this but have a look at chm2qch, Tool for converting Windows CHM files to Qt Help format.

How to link to a PDF file in Qt Assistant?

I use Qt Assistant as a help viewer and I have an internal link to a PDF file that is embedded into the compiled archive format. When I click on that link, nothing happens. How can I link to a PDF file that is embedded, click on the link and have an external application opened? I use Qt Assistant 4.7.3.
Short of bundling a program like Okular into your application release and launching it as an external process there isn't a native way of arriving at your solution. More options are discussed here as well, to sum it up it's either externally or converting the PDF to a QPixmap.
I don't think that this can work. To display a pdf file you need Acrobat or a similar (external) program, and this program needs a file to read. Why don't you store the pdf files outside the help file?

combine multiple pdfs(using url path) using tool like iText for dot net

Ho can I combine multiple pdfs(using url path) into one using tool like iText.
I am able to combine pdfsfrom my c# code using iText when the files are stored on my hard disk(local path).
But unable to combine when I am given the url to pdfs.
Thanks in advance
-Naresh
The PDF files must be downloaded in order to be combined.
So the question is: who will download the files, your app or the lib you are using?
PDFsharp cannot download PDF files from URLs yet. This could be implemented but I think it doesn't make much sense; you're much more flexible if you download the PDF files with your own code, retrying the download if it failed if you want.
Downloading them to MemoryStreams will do, no need to create temporary files.
I don't know if iText or iTextSharp will do the download for you.

Resources