catalyst / moodle-tool_pdfpages

A Moodle plugin for converting web pages to PDFs using various headless browser drivers
3 stars 2 forks source link

GitHub Workflow Status (branch)

PDF pages

An API to assist in downloading Moodle internal webpages as PDFs into the Moodle file system using a headless browser.

This plugin will not work by itself without further development work and is instead intended to be leveraged as an API by other Moodle plugins, to download PDFs of Moodle web pages as they appear in browser print engines.

  1. Installation
  2. Requirements
  3. Usage
  4. Testing Conversion
  5. License

Requirements

This plugin requires the following:

Installation

There are multiple drivers to use, each requires its own binary in order to access the headless browser for downloading of PDFs. Follow the instructions for whichever driver you would prefer to use. Note that the Qt browser under wkhtmltopdf is much older than the chromium browser, so the results of downloaded PDFs will vary according to the supported features for each.

Chromium driver

WKHTMLTOPDF driver

Usage

Use of the converter requires programmatic access, there in no frontend associated with this plugin, so you need to develop another module, or add this plugin to the dependencies of an existing Moodle plugin.

Only users with the system level capability tool/pdfpages:generatepdf can conducted conversions, as this is required to create the single use access key for the headless browser session.

Testing Conversion

In order to test how a URL will be converted and see the outcome, you can utilise the /admin/tool/pdfpages/test.php page in your browser. This will utilise the configured converter on the server side to carry out the conversion, creating the converted file in the Moodle file system and then serve up the PDF to the browser.

In order to access this page, the logged in Moodle user needs to be an Admin or have a role with the capability tool/pdfpages:generatepdf at the system level.

This page takes the following query parameters:

For example: https://mymoodle.com/admin/tool/pdfpages/test.php?url=%2Fcourse%2Fview.php%3Fid%3D2&converter=chromium&filename=test.pdf&options={"landscape":true}

This allows you to test any conversion candidates and see how well they translate into a PDF or whether alterations might need to be made, such as CSS changes to the page.

License

2021 Catalyst IT Australia

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

This plugin was developed by Catalyst IT Australia:

https://www.catalyst-au.net/

Catalyst IT