<< to CrossControl homepage

Support & Service Center

Showing PDF files in Qt

Printer-friendly versionPrinter-friendly versionPDF versionPDF version

Showing PDF files in Linux and Qt can be accomplished in several different ways.  One of the more popular ways is to use a program called Poppler to load and view PDF files.  In our experience, using Poppler on the ARM based displays is a bit slow to load and scroll through the file.  Because of this we have designed our demo application to utilize a Linux application called 'pdftocairo' which converts PDF documents to images (or other formats).  Some basic information on 'pdftocairo' can be found here: http://manpages.ubuntu.com/manpages/trusty/man1/pdftocairo.1.html.

In the attached demo application, it will scan for PDF documents in the '/opt' directory of the display.  If there are any PDF documents available in that directory it will list them in the list widget in the application.  Once a document is selected the user will have the option to 'Load' the document.  If this is the first time the document is loaded it will 'cache' the document which means it will use the 'pdftocairo' application to save each page of the PDF as an image.  Depending on the size of the PDF document this may take between 30 seconds and 5 minutes to cache the document.  Once cached the document will show on the screen.  The user can zoom, change pages and scroll through the page by dragging their finger on the document.  Once cached the document will load quickly on successive loads (1-2 seconds) and will not need to be cached again unless the cache is deleted.  There are some comments in the code that suggest how the initial cache time could happen in the background without freezing the display as is done in the application.

To load PDF specific libraries and applications onto the display:

  • Download the 'pdfViewer_v0.0.2.tar.gz' file from the attachments below and copy the file onto the '/opt' directory of the display
  • Log into the display via the terminal, navigate to the '/opt' directory and extract the file with 'tar -xf pdfViewer_v0.0.2.tar.gz -C /opt'
  • Once extracted, type 'ldconfig -C /opt/etc/ld.so.cache' to update the library references

Note: The LinX runtime must be installed for this to work as instructed above.  If it is not installed you can create the required library directories before installation or install the LinX RT first.

To load the PDF demo on the display (The PDF specific libraries and applications must be loaded from instructions above for the demo to function):

  • Download the 'PDF_Test.tar.gz' file and transfer over to the virtual machine
  • Extract the 'PDF_Test' folder and open the '.pro' file within that folder with Qt
  • Build the demo for the display of choice and deploy to the display (note: there is a compiled binary called 'PDF_Test' located in the folder for ARM based displays)

There is also a standalone PDF viewer in the PDF specific libraries and applications.  The 'readme.txt' file briefly describes its use.

Finally, there is a lot of information on the internet and free applications available for viewing PDF files in Qt.  Here is a good resource for free apps for Qt: http://qt-apps.org/ 

 

 

whatever