Dear Open edX community,
We have successfully launched our LMS using the Open edX Nutmeg release. Through theme customizations, we have tailored the LMS interface and the certificate templates to our requirements. However, we now face a challenge related to the delivery of these certificates. We wish to provide the option for users to download their certificates in PDF format directly from the LMS.
Currently, the method of downloading the certificate involves viewing it in a browser and using the Print (or CTRL + P) option to save it as a PDF. Unfortunately, this doesn’t result in a perfect fit on one page, and it requires students to modify some configurations on their end. To circumvent this inconvenience, we are exploring the possibility of generating PDF versions of the certificates and providing a direct download link to the students.
We have chosen pdfkit for the HTML-to-PDF conversion task and created a tutor plugin to listen for the “COURSE_CERT_AWARDED” signal and generate the corresponding PDF. Here’s a snippet of the code we are using:
import pdfkit
pdfkit_options = {
"dpi": 100,
"orientation": "Portrait",
"encoding": "UTF-8",
"margin-top": "0mm",
"margin-bottom": "0mm",
"margin-left": "0mm",
"margin-right": "0mm",
"page-width": "130mm",
"page-height": "140mm",
"zoom": 1,
"load-media-error-handling": "skip",
}
pdfkit.from_url(cert_url, file_path, options=pdfkit_options)
The main challenge we are facing is the installation of the necessary package, wkhtmltopdf, which pdfkit depends on. While pdfkit itself is easily installable via pip, wkhtmltopdf needs to be installed system-wide. In the Nutmeg version of tutor, each service runs in a separate Docker container, and we need to install wkhtmltopdf in the openedx Docker image.
We would appreciate any assistance or advice on how to install wkhtmltopdf in the openedx Docker image.
Thank you in advance for your help.