How to display a PDF in LVGL?

Description

Hi, I’m trying to create a pdf viewer in LVGL or implement a library that can extract text from a pdf file and display it as a textbox on screen. I have tried using online libraries in C to do so but many of them do not work that well. I tried a Docx reader but that was built in C++ and every time I try to compile LVGL libraries in C++, I get many compilation errors (I’m told there were many invalid conversions from void * to <lv_object_type>). If I could get LVGL to compile in C++ that would be a great alternate solution.

What MCU/Processor/Board and compiler are you using?

Zynq development board running on eclipse (through Xilinx SDK)

What LVGL version are you using?

8.1

What do you want to achieve?

I want to try to display a pdf on the screen - one that is scrollable.

What have you tried so far?

I have tried using online libraries such as pdfIO pdfToTXT and have tried running the program in C++ (works by itself but not with LVGL). @embeddedt and @kisvegabor if you could help me out that would be awesome!

Screenshot and/or video

You shouldn’t compile LVGL source files as C++; you’ll need to set your IDE to compile them as C files. Only the headers are designed to be included from a C++ file.

Thank you @embeddedt, that makes sense. Do you know how I can compile the LVGL source files as C source files inside Eclipse while still being able to compile C++ source files outside of LVGL? When I tried using a g++ compiler, it gave me the errors seen above. When I use a GCC compiler, all C++ files are ignored (no object files are created for these files). I want to test out if I can create a cross-compiled project with both C and C++ by seeing if I can import an add(2,3) function from a CPP file into a main.c file that would return 5. Do you know if there is any way I can do so or any way I can perform this cross-compilation inside Eclipse? Thanks!

It should hopefully be possible to right-click the folder and mark it as a C source folder. You have to leave the project itself as a C++ project to avoid running into the issues you stated. I haven’t used an Eclipse-based IDE like this in a while so I’m not exactly sure what the steps would be.

This is absolutely possible; it’s just a matter of configuring Eclipse to compile the files correctly.

Thank you @embeddedt. This took me a while but I finally figured it out. I thought giving the files a .c extension was enough to get the compiler to know that they should be compiled as C files. However, it was not enough, I had to right-click the folder, go to properties and change the extension on the compiler command from g++ to gcc. However, I’m still having a little bit of trouble getting a pdf viewer to work on LVGL. I’m thinking of downloading a Linux application since I’m running LVGL off of a Xilinx development board that works on an ARM processor. Do you have any ideas on how I can run a pdf viewer/ renderer (even as a separate application altogether) so when I click a button on the GUI I can display a pdf to the screen?

@pete-pjb if you have any ideas on how to do this, that would be much appreciated as well!

Hi @Matthew_Gerges,

I am sorry I have only just seen this!

I am also sorry, but I am not able to contribute to this particular situation. I hope you have found a way forward.

Kind Regards,

Pete