Project

General

Profile

Actions

Feature #19076

closed

Wordpress Pages to PDF

Added by Laurie Hurson about 1 year ago. Updated about 1 year ago.

Status:
Resolved
Priority name:
Normal
Assignee:
-
Category name:
WordPress Plugins
Target version:
Start date:
2023-10-23
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

Hi All,

A new request from the creator of a the PIR journal site....

https://pirjournal.commons.gc.cuny.edu/puppet-research-international-1-no-1/

They would like to allow visitors to download PDF versions of the articles. I suggested they upload PDFs to media library and make them available for download. But they don't have PDFs...and are hoping to do something like this PDF download option:

https://arabstages.org/?p=3473&preview=true

It seems some kind of tool is running the download on the Arab stages site, but I couldn't figure out the mechanism.

Can you look at this example and see if we might be able to make it possible on the PIR site?

Thanks,
Laurie


Files

Actions #1

Updated by Boone Gorges about 1 year ago

The link on the arabstages.org site is created by the plugin wp-posts-to-pdf. The plugin is no longer available on the Commons for activation; see #10858.

I've added Scott as a watcher to see if he has updated ideas about plugins that provide this functionality. In the linked ticket, he recommends Anthologize. But I don't think that's a good substitute - Anthologize requires users to create a PDF document manually, but I think the current use case is for automatically-generated PDFs of each single post.

On other projects, I've used dk-pdf and found it to be OK. https://wordpress.org/plugins/dk-pdf/ We don't currently have this plugin on the Commons. If Scott doesn't have other ideas about how it could be accomplished, perhaps we could add dk-pdf or something like it.

Actions #2

Updated by scott voth about 1 year ago

No, I don't think we have any PDF generator for single posts.

Actions #3

Updated by Boone Gorges about 1 year ago

  • Category name set to WordPress Plugins
  • Status changed from New to Staged for Production Release
  • Target version set to 2.2.1

Thanks, Scott. Let's go with dk-pdf for now, since I'm somewhat familiar with it. https://github.com/cuny-academic-commons/cac/commit/7200933324033ad4e271ccb14b3b5d12d254c9a8

Laurie, it will be available for activation after today's release.

Actions #4

Updated by Boone Gorges about 1 year ago

  • Status changed from Staged for Production Release to Resolved
Actions #7

Updated by Raymond Hoh about 1 year ago

The dk-pdf plugin is causing a fatal error when attempting to create the PDF:

Fatal error: Uncaught Mpdf\MpdfException: Temporary files directory "/wp-content/plugins/dk-pdf/tmp" is not writable in /wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Cache.php:23
Stack trace:
#0 /wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Mpdf.php(981): Mpdf\Cache->__construct()
#1 /wp-content/plugins/dk-pdf/includes/dkpdf-functions.php(164): Mpdf\Mpdf->__construct()
#2 /wp-includes/class-wp-hook.php(310): dkpdf_output_pdf()
#3 /wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
#4 /wp-includes/plugin.php(565): WP_Hook->do_action()
#5 /wp-includes/class-wp.php(796): do_action_ref_array()
#6 /wp-includes/functions.php(1335): WP->main()
#7 /wp-blog-header.php(16): wp()
#8 /index.php(21): require('/...')
#9 {main} thrown in /wp-content/plugins/dk-pdf/vendor/mpdf/mpdf/src/Cache.php on line 23

By default, the dk-pdf plugin attempts to write files to the /wp-content/plugins/dk-pdf/tmp/ directory. However, our filesystem set up is restricted so this was causing the fatal error. Fortunately, the dk-pdf plugin has a filter on their temp directory so I just wrote a quick filter that allows for writing to the /wp-content/uploads/dkpdf/ directory: https://github.com/cuny-academic-commons/cac/commit/a619cbf486a76d5c1d60e1e8a29c92f677d92745. This fix is live and it looks like this allows for the dk-pdf plugin to render the PDF now.

Actions #8

Updated by Laurie Hurson about 1 year ago

Thanks Ray! I can see that this is working now!

Actions #9

Updated by Boone Gorges about 1 year ago

Thanks for tracking this down so quickly, Ray!

Actions

Also available in: Atom PDF