Customizing Output of PDF QR Code in Reports Plugin

I am looking for a process overview of the OMEKA Reports Plugin. We are attempting to customize the QR Code generator to output a PDF sized to the dimensions of our label printer, and include additional item metadata fields. By Default, PdfQrCode reports have the QR Code (via Google Charts) and the item title. We’d like to add “Creator”, “Item #” and “Location” next to the QR code as well. So two main goals:

  1. resize the PDF output to our label type (2” x 1”; Zebra Label Type 83259); link)
  1. Under Item Title, include item metadata fields “creator”, “id” & “location”

re: Resizing the PDF Output, Lines 57-79 seem the most relevant. We have been able to modfy these specifications and change the layout of items in PDF report. We will be tweaking it some more, but if anyone has already performed this size/layout modification and can share words of wisdom or even code, would be very grateful.

re: Adding Metadata Fields - I am poking around Report.php to add metadata elements to the reports query functionality - is this the right place to start?? (Report.php to make sure the relevant metadata elements are included with the query resuts). Then I am looking at PdfQrCode.php (lines 215-226) which I believe places the item title next to the QR code. I can duplicate this chunk, replacing $titles to $creators or something similar??

In terms of the Reports Plugin Process, from what I can tell it seems to go like this:

  1. PdfQrCode.php loads Report.php and Generator.php.

  2. Report.php queries the OMEKA database, returning public item metadata fields including $id; $name; $description; $query; $creator; $modified (lines 15-24, Report.php. If I wanted to include $Location, should I include “public $Location;” somewhere in this section?? (Lines 15-24; Report.php)??

  3. PdfQrCode.php then ingests the query results from Report.php, and formats the PDF document and metadata fields - is this right?? In particular, it looks like Lines 215-226 of PdfQrCode.php places the item “title” next to the QR Code in the PDF. If I wanted to add additional metadata fields, should I duplicate Lines 215-226 and modify from $titles to $creator for example??

  4. Export PDF FIle

Any insights to the overall Reports Plugin Process, as it relates to these .php files would be very helpful. I am digging through all the forum posts and legacy developer documentation in the meantime - hoping by posting here, I can quickly get directions from someone who has been here before and customized the Reports Plugin.

Thank you,
Jonathan Cachat, PhD

PdfQrCode is where all the PDF generation code lives, so yes, it’s there that you want to make changes to the sizing and content included. You correctly identified the part that draws the title, and yes, to some extent you’d just duplicate that (though you’ll have to adjust the position so you’re not drawing your new text on top of the existing stuff).

Your talk about Location I’m not as clear on. The “Report.php” file is the model for a report, and the metadata stored there is metadata about the report itself as a whole, not the individual items. So if you’re looking to say, print a location for each item, you wouldn’t need to modify the Report model at all. In terms of having access to item metadata when actually generating the report, you always have access to all the item’s metadata through accessing the $item variable directly or using metadata() calls or whatever.

1 Like

Thanks for the quick reply, and clarification.

Location is a custom metadata-field at the item level that does describe an internal storage location - apologies for not explicitly mentioning that.

Glad I was correctly identifying where it draws the title, I’ll play around and see what I can come up with.

Lastly, along these lines - the Google Charts API is depreciated, and according to Google it shouldnt even return a QR Code. In this specific situation tho, PdfQrCode.php does seem to properly grab a unique QR code through this depreciated API - which is curious.

I am in the process of porting over to an open-source QR Code API service (Google Dev Forums suggested goqr.me or image-charts.org - I am curious if there is any active development to bring the Reports plugin up-to-date, esp regarding the status of Google Charts API. If not, should I get a clean version of my code changes pulled aside and send it to someone on your end?? I am sure there are plenty of people combing thru GitHub looking for the most recent and compatable versions of these plugins - if it works, and its of value to the OMEKA community, I am find posting the code update or sharing directly.

There is no active development on the Reports plugin, at least from the Omeka team itself.

You can certainly look at updating the code to remove the Google Charts dependency (that has been “deprecated” for many years now). My suggestion would be to look into something like TCPDF to replace the usage of Zend_Pdf entirely. TCPDF has built-in QR code support, so you wouldn’t need to depend on any external service to generate the codes, but you’d have to rewrite the “PdfQrCode” class to switch libraries like that.

You can always share the code publicly however you wish, including sending it back to us as a pull request.

1 Like