2017 © Pedro Peláez
 

silverstripe-module queuedjobs-pdf-export

Export PDFs using QueuedJobs

image

psukhedelos/queuedjobs-pdf-export

Export PDFs using QueuedJobs

  • Tuesday, January 24, 2017
  • by PsukheDelos
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SilverStripe Queued Jobs PDF Export Module

Maintainer Contact

Glen Peek, (*1)

Use

By default, this job starts at the first page and produces PDFs in batches of 20, (*2)

If you would like to create a custom job, enter the desired batch size as the first parameter and the Page ID of the page you'd like the job to start on as the second parameter., (*3)

In the example below, we have specified to run the job in batches of 42 starting at Page 1024. alt text, (*4)

Requirements

  • CWP
  • SilverStripe Queued Jobs Module 2.x
  • This module requires that pdf_export is enabled. For example, you may include in your config.yml:, (*5)

    BasePage: 
    pdf_export: 1
    
    
  • Currently, only works with themes that are self contained (e.g. in one folder). For instance, the default CWP theme does not work as it relies on a separate folder for bootstrap styling., (*6)

Version info

The master branch of this module is currently aiming for SilverStripe 3.x compatibility, (*7)

Documentation

The Queued Jobs PDF Export module provides a process for exporting all Live Pages to PDF., (*8)

By default, when PDF export is enabled on a CWP site, a download PDF link is added to all BasePages. The first time this link is hit, a PDF is generated of the page and then served to the user. On subsequent requests, the already generated PDF is served to the user instead of regenerating the PDF., (*9)

However, it was discovered that this was causing some CWP instances to overload. Bots crawling the web would happen upon a CWP site. They would then go about hitting every path they could. In doing so, they would hit the generatePDF function of every page in a short space of time. As many pages across the site had not had PDFs generated, this would cause the CWP instance to overload as it would now have to generate countless PDFs., (*10)

This was designed to prevent PDF Generation from overloading CWP instances by pushing generation of PDFs out to QueuedJobs to be run during off peak hours. This would ensure that all pages had a cached, pre-generated PDF available for download., (*11)

Future Work

At present, this module would be run every so often on off peak hours. Ideally, the Export PDF Job would be run once over a website to generate all PDFs initially. BasePage could then be modified to published a new PDF every time it is updated / published., (*12)

Quick Usage Overview

  • To run, select the ExportPDFJob from the Jobs tab of the CMS and run. Ideally, this should be done during off peak hours.

The Versions

24/01 2017

dev-master

9999999-dev https://github.com/PsukheDelos/queuedjobs-pdf-export/

Export PDFs using QueuedJobs

  Sources   Download

BSD-3-Clause

The Requires

 

by Glen Peek

jobs export silverstripe pdf cwp