Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary error #54

Closed
abross86 opened this issue May 18, 2023 · 1 comment
Closed

Binary error #54

abross86 opened this issue May 18, 2023 · 1 comment

Comments

@abross86
Copy link

abross86 commented May 18, 2023

I am getting a binary error whenever I try to convert(). I installed using composer, running PHP 8.2.5, node 16.16.0 on macOS. I have installed chromium and can see the chromium process

Update: I noticed that the Chromium process is actually crashing immediately. It runs fine outside of the Apache environment on the machine, both headless and not. This is on macOS 13.3.1 (Intel), and I wonder if it may be caused by code-signing/sandbox issues. Has anyone gotten puppeteer to work in a similar environment?

Any help would be appreciated. Thanks!

The error:
PHP Fatal error: Uncaught Spiritix\\Html2Pdf\\ConverterException: Binary error: node:internal/process/promises:279\n triggerUncaughtException(err, true /* fromPromise */);\n ^\n\n[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<ErrorEvent>".] {\n code: 'ERR_UNHANDLED_REJECTION'\n}\n in /HTTPServer/htdocs/phppdf/vendor/spiritix/php-chrome-html2pdf/src/Spiritix/Html2Pdf/Converter.php:188\nStack trace:\n#0 /HTTPServer/htdocs/phppdf/index.php(41): Spiritix\\Html2Pdf\\Converter->convert()\n#1 {main}\n thrown in /HTTPServer/htdocs/phppdf/vendor/spiritix/php-chrome-html2pdf/src/Spiritix/Html2Pdf/Converter.php on line 188

Here is a simple example that throws the error:

require __DIR__ . '/vendor/autoload.php';

use Spiritix\Html2Pdf\Converter;
use Spiritix\Html2Pdf\Input\UrlInput;
use Spiritix\Html2Pdf\Output\EmbedOutput;

$input = new UrlInput();
$input->setUrl('https://www.google.com');
$converter = new Converter($input, new EmbedOutput() );
$converter->setNodePath('/usr/local/bin/node');

$converter->setOptions([
	'displayHeaderFooter' => false,
    'printBackground' => true,
    'mediaType' => 'screen',
    'lowquality' => true,
    'dpi' => 75,
    'pageWaitFor' => 1000,
    'landscape' => false,
    'scale' => 0.86,
    'margin' => array( 'left' => '0.5in', 'top' => '0.5in', 'right' => '0.5in', 'bottom' => '0.5in' )
]);

$pdfData = $converter->convert();

ob_start();
$pdfData->embed('out.pdf', false);

@spiritix
Copy link
Owner

spiritix commented Apr 4, 2024

Please try again with the latest version

@spiritix spiritix closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants