maxchene / kirby-pdf

Choose a PDF engine to convert HTML pages to PDF with Kirby CMS
MIT License
23 stars 0 forks source link

Installation without composer doesn’t work #1

Open getflourish opened 1 month ago

getflourish commented 1 month ago

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
maxchene commented 1 month ago

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

getflourish commented 1 month ago

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 commented 1 month ago

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…

maxchene commented 1 month ago

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

getflourish commented 1 month ago

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?

maxchene commented 1 month ago

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

getflourish commented 1 month ago

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 commented 1 month ago

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 :)

maxchene commented 1 month ago

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