Jump to content

Topic on Extension talk:PdfBook

Failed to load PDF document.

10
Squeak24 (talkcontribs)

Hi

I am having a bit of an issue with PdfBook not exporting to PDF.

I have an issue where I am getting an error

Error 
Failed to load PDF document.

I have done what DGessei suggests on FreeBSD installation - fails to generate pdf but does generate HTML substituting the path to HtmlDoc with what I have, but still get the same error.

I am running: RHELV7 MediaWiki 1.35.3 PHP 7.4.22 (apache2handler) MariaDB 10.5.11-MariaDB


I have set my path to HTMLDoc to /var/lib/snapd/snap/htmldoc/current

I am running it on a server with TLS, I did see HtmlDoc only works with http:// rather than https:// so not sure if that is a thing or if that's something which isn't anything to be worried about.


Any help is appreciated.

Igorabsorto (talkcontribs)

Hi @Squeak24 I don't think it is an issue with TLS.

As your issue seems similar to the one DGessei described, can you confirm that:

  1. Exporting as HTML works action=pdfbook&format=html
  2. Invoking HTMLDoc from command line works

thanks!

Squeak24 (talkcontribs)
Igorabsorto (talkcontribs)

@Squeak24 Nice, it seems that HTMLDoc is working fine them.


Please check your wiki log searching for 'PdfBook' and also look the httpd-error.log. In DGessei there was some useful error in the httpd log.

We have to keep digging, I'm not aware of what could be possibly happening, I'm hopeful the logs will help us.

Squeak24 (talkcontribs)

Just checked the httpd-error log, and I think I know what's not working, just how to make it work.

The error I got is:

[Thu Aug 12 12:29:20.767533 2021] [core:notice] [pid ****:tid ******] AH00052: child pid **** exit signal Segmentation fault (11)

sh: /var/www/html/****/images/pdf-book-cache-f9615d5465514db4928d99bae7e5c29e: Permission denied

sh: /var/www/html/****/images/pdf-book-cache-f9615d5465514db4928d99bae7e5c29e: Permission denied

So I created the folder pdf-book-cache-f9615d5465514db4928d99bae7e5c29 in the images directory and chmod to 755.

But when I try and run the PdfBook for the help category I still don't get a PDF output. The HTML is still blank.

The error this time is:

sh: /var/www/html/wind/images/pdf-book-cache-3111d94f42c206868284391c0693d1ce: Permission denied

I can upload images OK. The permissions are set to 755 and the owner is root. I guess the owner should be www-data or httpd

Any help is appreciated.

Igorabsorto (talkcontribs)

@Squeak24 Great, we have some directions now :)

The owner of the images directory should be httpd (for Apache) or www-data (nginx).

Just run chown recursively on the directory and you should be good to go.

Squeak24 (talkcontribs)

Apologies for the delay. I have been a little run of my feet recently.


I have tried to do what has suggested. I am just experimenting on a Ubuntu machine as well.


But I am still having the same issues. The Wiki I am working on is part of a farm using symbolic links, this will be the way we will be doing things in the future. After further experimentation I can't even upload images.


I get the error:

Uploading not possible "Could not open lock file for "mwstore://local-backend/local-public/"


I have tried to change the image directory and upload path in the Local LocalSettings.php, but still nothing.

When I include the full path:

/var/www/html/field1/images

The image uploads, but doesn't display. The URL looks something like:

http://field1.tld/index.php/Image/path to image/image.png

But if I take out the index.php and change the Image to image the file shows.

I did get the images working on a farm, but for some reason it's not working now.

Any help is appreciated.

Squeak24 (talkcontribs)

So, I got it working on my Ubuntu device by using the code:


$wgUploadDirectory = "/var/www/html/field1/images";

$wgUploadPath = "/images";


But it's still not working on Red Hat! This is annoying.

Supermozzi (talkcontribs)

I was also having problems with the empty PDF being generated. The settings and permissions were correct. I could see the file being generated in the /var/www/html/images folder, but with zero size. Passing the 'format=html' parameter worked.

Looking at the code I realized that the information would only be generated if I passed the 'format' parameter.

I was calling it like this:

www.example.org/wiki/index.php?title=Main_Page&action=pdfbook

And it only works like this:

www.example.org/wiki/index.php?title=Main_Page&action=pdfbook&format=single

You need to pass the 'format' parameter, otherwise the file is generated empty.

Produto Versão
MediaWiki 1.42.1
PHP 8.2.20
ICU 72.1
MariaDB 10.11.6
Squeak24 (talkcontribs)

I decided to go a different route and use wkhtmltopdf, I am doing it for a full Wiki, convert the Wiki to HTML files, then combine all those HTML files into one single HTML file then convert to PDF. Using wkhtmltopdf you can also generate a functioning table of contents.

If you need only certain categories, again, you can do that by getting all the URLs from the API and just convert those pages.

I still have a few things to iron out with the code, I am getting one error message now that I need to address and verify my tests today have worked, but I do plan to include the scripts on my MW Companion, I will be publishing it on gitHub. Just tring to find the time to do these things.

Reply to "Failed to load PDF document."