Update On My Gsoc Project


I realize it has been a long time since the start of GSoC and I didn’t write any update blogs on the status of my project, I’m currently working on Okular to extend it to have better support for custom image stamps. Right now, Okular doesn’t fully support representing Stamp Annotations, resulting in not being able to render Stamps or not being able to save custom ones so that other viewers are able to render them.

I’m currently working under the mentorship of Albert Astals Cid, whom I’d like to thank a lot for his continuous support and help. He has been really supportive and made the GSoC period a really fruitful journey so far.

Overview of The Work Done

Poppler and The Qt5 Frontend Side

During the community bonding period, I tried familiarizing myself with the code more, especially because Poppler, the backend PDF rendering library that Okular uses, is a bit large and complex. I kept contact with Albert during this period, and he thankfully helped me by guiding me on which parts of the library to focus on more while reading the code.

After the end of the community bonding period, I began reading the PDF specifications to understand what changes need to be done to the Annotations module in the library. First, we agreed on creating a new class to represent Images submitted from users of the library. This class contains all of the necessary image parameters that we need in order to be able to save them inside the document so that it can be rendered correctly by viewers, like the color space of the image, the width and height, and the image data of the image itself. After testing this and making sure that it actually saves the values to the PDF document, we decided that we need to export the new API to the Qt5 Wrapper of Poppler. Doing this means that we need to figure out a way of converting a QImage (since QImages contains all of the necessary information about the image that we are going to need) to the new data structure created for Poppler, so that it can understand it and save the new data correctly to the PDF document.

This intermediate layer is where the work became somewhat complicated, since the QImage has a lot of different formats, and each format represents colors using different numbers of bits, as well as different alignments. So, we had worked a lot on it to make sure it “works” for the multiple formats we tried so far, it still needs more work to make sure that it’s optimal and working well for everything.

Here’s an example of what currently have been achieved so far (this on Qt5 demo app from the Qt5 Wrapper of Poppler):

Okular’s Side

So far, on Okular’s side we agreed to extend the Stamp Annotation implementation to support having a QImage, this QImage will be sent to the Qt5 Wrapper library using Okular’s PDF Generator (Plugin to Okular to support the PDF format). This generator mainly transforms Okular’s Annotation to the Qt5-Wrapper Annotation, during this transformation is where we will pass the new QImage.

Right now, we can pass the QImage from Okular to Qt5, however the scaling of the passed image isn’t correct so it becomes something like this (on the Qt5 demo app and other viewers as well):


In the upcoming days, I’ll focus more on the scaling issue to make sure that Okular’s stamps get saved as expected. Then, hopefully we can do other improvements on both Okular’s side as well as the Qt5-Wrapper/Poppler side.

I’m really enjoying working on this so far, I didn’t imagine myself working on something complex like a PDF rendering library, but this, as well as Albert’s help, is what’s giving me inspiration to keep going and finish the project. Wish me luck!

Written on July 11, 2021