pontedilana / php-weasyprint

PHP library allowing PDF generation or snapshot from an URL or an HTML page. Wrapper for Kozea/WeasyPrint
MIT License
52 stars 11 forks source link

weasyprint: error: unrecognized arguments: --format #2

Closed khonyuen closed 2 years ago

khonyuen commented 2 years ago

The exit status code '2' says something went wrong: stderr: "usage: weasyprint [-h] [--version] [-i] [-e ENCODING] [-s STYLESHEET] [-m MEDIA_TYPE] [-u BASE_URL] [-a ATTACHMENT] [-p] [-O {images,fonts,all,none}] [-v] [-d] [-q] input output weasyprint: error: unrecognized arguments: --format C:\Users\AEM\AppData\Local\Temp\php_weasyprint61cbe3514c1101.17556704.pdf " stdout: "" command: C:\Users\AEM\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\weasyprint.exe --format pdf "http://www.github.com" "C:\Users\AEM\AppData\Local\Temp\php_weasyprint61cbe3514c1101.17556704.pdf".

if i run in command line , i get same error

when i run this command is ok weasyprint https://example.com weasyprint-website.pdf

endelwar commented 2 years ago

Hi @khonyuen, which version of weasyprint are you running? can you report the output of weasyprint --info? --format was deprecated in version 53 and will be removed in a future release.

endelwar commented 2 years ago

Ok, I missed the new 54.0b1 beta release of WeasyPrint, where --format is indeed removed.

As a quick workaround you can unset the format option:

$weasyprint = new \Pontedilana\PhpWeasyPrint\Pdf('/usr/local/bin/weasyprint');
$weasyprint->setOption('format', null);

I'll release a new version of php-weasyprint to accommodate this change in upstream.

endelwar commented 2 years ago

I've released version 0.10.0 (and a tests fix release 0.10.1) that implements support for WeasyPrint 54

https://github.com/pontedilana/php-weasyprint/releases/tag/0.10.1