kirby-pdf icon indicating copy to clipboard operation
kirby-pdf copied to clipboard

Installation without composer doesn’t work

Open getflourish opened this issue 1 year ago • 9 comments

I’m excited about this plugin!

I tried installing it by downloading the source and moved it to /site/plugins/pdf

It looks as if Kirby picks it up, but the plugin itself throws an error:

Class "Maxchene\KirbyPdf\KirbyPdf" not found

image

getflourish avatar Oct 04 '24 08:10 getflourish

Thanks for your feedback. I'll look into it quickly.

maxchene avatar Oct 04 '24 08:10 maxchene

I now installed it with composer which does solve that issue. I never used composer before, but apparently, it’s straightforward.

I also installed the macOS build of wkhtmltopdf.

When I try to open a PDF, the PHP server hangs. When I kill it, I get these error messages:

WKHTMLTOPDF didn't return any data

Any idea how I can check if wkhtmltopdf is installed properly?

image

getflourish avatar Oct 04 '24 08:10 getflourish

Ah, I just checked: wkhtmltopdf is installed as I can use it on the command-line.

So I need to find out why it’s not returning anything to the plugin…

getflourish avatar Oct 04 '24 08:10 getflourish

You can check if WkHtmltoPdf is installed in your terminal by running : wkhtmltopdf --version This should print the version installed (preferably with Qt patched)

Then you can try to render google homepage by running : wkhtmltopdf https://google.com google.pdf And then check that google.pdf file created is ok

maxchene avatar Oct 04 '24 08:10 maxchene

wkhtmltopdf works from the command-line. I now have the Google Homepage ready to print :D

I wonder if my PHP on macOS has access to it? Permission issues?

getflourish avatar Oct 04 '24 09:10 getflourish

Sure, could be a permission issue, make sure that the php user can execute wkhtmltopdf binary

maxchene avatar Oct 04 '24 09:10 maxchene

I ran this directly in a Kirby template and it worked. Okay, I will now try to use the plugin with a very simple template and debug further.

Sorry, this is now unrelated to the original issue and I might open another one once I figured out why it’s not working. But we’ll get there, I’m sure :)

<?php
  $command = '/usr/local/bin/wkhtmltopdf https://www.google.com output.pdf';
  $output = shell_exec($command);
?>```

getflourish avatar Oct 04 '24 09:10 getflourish

Okay, solved it. Any kind of JavaScript on a template seems to break wkhtmltopdf and freezes the server. It works with simple templates (which I will need anyway). But I better make sure that I disable rendering of any template other than the specific PDF ones :)

getflourish avatar Oct 04 '24 09:10 getflourish

I'll still look into install without composer. But i'll open another one for javascript issue

maxchene avatar Oct 04 '24 09:10 maxchene