Jump to content

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."

Error: Call to undefined method WikiPage::factory()

2
Bcnx (talkcontribs)

Hi,

I get this error when clicking the PdfBook link:

[0e07492624b529bc2ce75cd0] /wiki/index.php?title=Category:Aquabio&action=pdfbook Error: Call to undefined method WikiPage::factory()

I have the latest 3.0.0 version and am using PHP 8.2.

What could the cause be?

Thanks,

BC

2A02:1810:2508:8400:5FB0:2B57:FB4D:C2FB (talkcontribs)

OK, it seems there is a later version, 3.1.0, but the download link on the Extension page point to 3.0.0. Someone should rectify that.

Reply to "Error: Call to undefined method WikiPage::factory()"

And once more, with frustration...

3
Slgrandson (talkcontribs)

To developers @Nad: /@Igorabsorto:

On Miraheze, PdfBook is currently on the chopping block as the MW 1.38 era closes in (linked statement by Universal Omega (talk · contribs)). Not much to add here, except my experimentation last month spat out a local error message that went:

Cannot display PDF (Title.pdf is of invalid format)

...and forced me to remove the extension from my wiki's lineup. (Details at Meta's Community noticeboard.)

A real shame, as something like it would sure come in handy for my future books. Let's hope it actually gets fixed soon enough....

P.S. To @Bawolff: Any further assistance you might provide?

(MW 1.37.2/PHP 7.4.28) --Slgrandson (talk) 11:53, 5 June 2022 (UTC)

Bawolff (talkcontribs)

Those are some scary looking regexes...


Nothing looks particularly incompatible at a glance, except probably $wgParser should be replaced with the equivalent MediaWiki\MediaWikiServices::getInstance()->getParser().


I dont really care about this extension so i probably wouldn't fix it myself, but if you want help fixing it i would be willing to offer advice.

Txantimedia (talkcontribs)

This extension works with php 7.4.30 but fails with php 8.0. Is it still being maintained?

Exception caught inside exception handler: [d252db5c937becb1babd2770] /index.php/Main_Page Error: Call to undefined method User::isLoggedIn() Backtrace: from /home/vvfhorg/public_html/wiki.vvfh.org/extensions/PdfBook/PdfBook.hooks.php(212) 0 /home/vvfhorg/public_html/wiki.vvfh.org/includes/HookContainer/HookContainer.php(338): PdfBookHooks::onSkinTemplateNavigation() 1 /home/vvfhorg/public_html/wiki.vvfh.org/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook() 2 /home/vvfhorg/public_html/wiki.vvfh.org/includes/HookContainer/HookRunner.php(3485): MediaWiki\HookContainer\HookContainer->run() 3 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinTemplate.php(1187): MediaWiki\HookContainer\HookRunner->onSkinTemplateNavigation() 4 /home/vvfhorg/public_html/wiki.vvfh.org/skins/Vector/includes/SkinVector.php(424): SkinTemplate->runOnSkinTemplateNavigationHooks() 5 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinTemplate.php(1541): Vector\SkinVector->runOnSkinTemplateNavigationHooks() 6 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinTemplate.php(782): SkinTemplate->buildContentNavigationUrlsInternal() 7 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinTemplate.php(202): SkinTemplate->getPortletsTemplateData() 8 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinMustache.php(81): SkinTemplate->getTemplateData() 9 /home/vvfhorg/public_html/wiki.vvfh.org/skins/Vector/includes/SkinVector.php(564): SkinMustache->getTemplateData() 10 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinMustache.php(58): Vector\SkinVector->getTemplateData() 11 /home/vvfhorg/public_html/wiki.vvfh.org/skins/Vector/includes/SkinVector.php(455): SkinMustache->generateHTML() 12 /home/vvfhorg/public_html/wiki.vvfh.org/includes/skins/SkinTemplate.php(150): Vector\SkinVector->generateHTML() 13 /home/vvfhorg/public_html/wiki.vvfh.org/includes/OutputPage.php(2807): SkinTemplate->outputPage() 14 /home/vvfhorg/public_html/wiki.vvfh.org/includes/exception/MWExceptionRenderer.php(157): OutputPage->output() 15 /home/vvfhorg/public_html/wiki.vvfh.org/includes/exception/MWExceptionRenderer.php(76): MWExceptionRenderer::reportHTML() 16 /home/vvfhorg/public_html/wiki.vvfh.org/includes/exception/MWExceptionHandler.php(107): MWExceptionRenderer::output() 17 /home/vvfhorg/public_html/wiki.vvfh.org/includes/exception/MWExceptionHandler.php(202): MWExceptionHandler::report() 18 /home/vvfhorg/public_html/wiki.vvfh.org/includes/MediaWiki.php(585): MWExceptionHandler::handleException() 19 /home/vvfhorg/public_html/wiki.vvfh.org/index.php(53): MediaWiki->run() 20 /home/vvfhorg/public_html/wiki.vvfh.org/index.php(46): wfIndexMain() 21 {main}

Reply to "And once more, with frustration..."

Generates empty pdf document

1
Pspviwki (talkcontribs)

When using the extension it generates an empty pdf file, message in error log: PHP Deprecated: Use of $wgParser was deprecated in MediaWiki 1.32. [Called from MediaWiki::performAction in ...mediawiki/includes/MediaWiki.php at line 543] in ..mediawiki/includes/debug/MWDebug.php on line 375. Used for single page generation, format=single.

Installation: MediaWiki 1.37.1, PHP 7.4.27, MariaDB 10.6.5-MariaDB, ICU 70.1, PdfBook 2.0.5,2021-07-19.

Reply to "Generates empty pdf document"

Make PdfBook: The generated PDF is too large for a complete display.

1
94.31.87.198 (talkcontribs)

A 4 byte PDF is generated. This PDF cannot be complete viewed/opened.

Reply to "Make PdfBook: The generated PDF is too large for a complete display."

FreeBSD installation - fails to generate pdf but does generate HTML

2
DGessel (talkcontribs)

The following procedure yielded a registered installation but it does not seem to generate any pdf output:

portmaster -Rd textproc/htmldoc

cd /usr/local/www/mediawiki/extensions

git clone https://gitlab.com/organicdesign/PdfBook.git

cd ..

ee LocalSettings.php

add

wfLoadExtension( 'PdfBook' );

and any settings following

apachectl graceful

and check https://XXX.XXX.XXX.XXX/mediawiki/index.php/Special:Version


Adding the action tab option successful directs to https://XXX.XXX.XXX.XXX/mediawiki/index.php?title=Upgrading_FreeBSD&action=pdfbook&format=single but yields a

ERROR Failed to load PDF document.


the pdf-book-cache- files are empty.  

The log file shows:

2021-06-05T03:06:43 Gessel talk contribs block ⧼pdflogentry⧽ (User:Gessel exported as a PDF book)


https://XXX.XXX.XXX.XXXmediawiki/index.php?title=Main_Page&action=pdfbook&format=single


also fails, however export as HTML works.


http://www.foo.bar/wiki/index.php?title=Main_Page&action=pdfbook&format=html and generates a valid cache file and presents it to the browser (looks lovely).


The command line

htmldoc --webpage -f postscript-output.pdf test-doc.html

works as expected, so there's something about the command structure calling htmldoc that isn't parsing correctly.

DGessel (talkcontribs)
Reply to "FreeBSD installation - fails to generate pdf but does generate HTML"

Can PdfBook handle Semantic Mediawiki Inline Queries?

2
AID-PMBD (talkcontribs)

Hello,


I'm using PdfBook on a Mediawiki 1.31 Installation and want to export Sites that are using inline queries (#ask) to display content. When exporting those sites as PDF, the query content doesn't show up. Can the extensions handle this? If yes, does someone have an idea as to where I went wrong?

AID-PMBD (talkcontribs)

I managed to reach the creator of PDFBook. The extension can handle Semantic Queries in general, however it doesn't seem to be able to handle if the Output of the Query is a table. I decided to use Mpdf or the "Print Version" instead.

Reply to "Can PdfBook handle Semantic Mediawiki Inline Queries?"

Category print and internal links

1
Frank V Damme (talkcontribs)

I generate a book per category which works well. Was wondering though if it were possible to include the page titles. ATM, a category with pages containing 3, 4 and 6 headers respectively will result in a pdf containing 13 chapters.


I was also wondering if there was a way to keep internal links? If a page links to another one in the same category, it will also appear in the same PDF but the link to it leads to the original site (full url).

Reply to "Category print and internal links"

Are there any configuration for Page Header and Footer n HTML Format

1
147.1.18.25 (talkcontribs)

Are  there any configuration for Page Header and Footer n HTML Format?


Kindly help me.

Reply to "Are there any configuration for Page Header and Footer n HTML Format"
147.1.18.25 (talkcontribs)

PDF Format is good. However html Table border is missing in PDF, Could anyone help me on this issue?

Reply to "PDF Format issue"