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

[QUESTION] No reader found for type Mpdf. (same when try export with DomPDF in ShouldQueue) #2531

Closed
4 tasks done
gordios opened this issue Feb 2, 2020 · 11 comments
Closed
4 tasks done

Comments

@gordios
Copy link

gordios commented Feb 2, 2020

Prerequisites

Versions

  • PHP version: 7.1.0
  • Laravel version: 5.8.*
  • Package version: 3.1.0

Description

I try to store large PDF file with arround 5000 rows with Export class implementing ShouldQueue interface. when job start it failed on "AppendQueryToSheet" step and in laravel.log file i see "No reader found for type Mpdf". Also i try to use DomPDF instead and i've seen same error. "No reader found for type DomPDF".

To reproduce this issue just try to store PDF file with ShouldQueue on Export. I've used for PDF driver Mpdf in config file. ("mpdf/mpdf": "^8.0.4" installed)

Additional Information

My config/excel.php (PDF driver)

Capture d’écran 2020-02-02 à 21 09 30

My controller:

Capture d’écran 2020-02-02 à 18 49 03

My export generated using custom query:

Capture d’écran 2020-02-02 à 18 55 57

My export shared service:

Capture d’écran 2020-02-02 à 18 57 42

My terminal when job in queue start:

Capture d’écran 2020-02-02 à 18 59 59

My laravel.log file:

"[2020-02-02 18:03:52] local.ERROR: No reader found for type Mpdf {"exception":"[object] (PhpOffice\PhpSpreadsheet\Reader\Exception(code: 0): No reader found for type Mpdf at /home/vagrant/archive/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php:71)
[stacktrace]
#0 /home/vagrant/archive/vendor/maatwebsite/excel/src/Writer.php(110): PhpOffice\PhpSpreadsheet\IOFactory::createReader('Mpdf')
#1 /home/vagrant/archive/vendor/maatwebsite/excel/src/Jobs/AppendQueryToSheet.php(88): Maatwebsite\Excel\Writer->reopen(Object(Maatwebsite\Excel\Files\RemoteTemporaryFile), 'Mpdf')
#2 [internal function]: Maatwebsite\Excel\Jobs\AppendQueryToSheet->handle(Object(Maatwebsite\Excel\Writer))"

@gordios
Copy link
Author

gordios commented Feb 3, 2020

Can you help me please...? Export PDF with queue not working...

@GlennM
Copy link
Contributor

GlennM commented Feb 4, 2020

Have you already tried explicitly defining \Maatwebsite\Excel\Excel::MPDF as mentioned on MPDF export format?

@gordios
Copy link
Author

gordios commented Feb 4, 2020

@GlennM , Yes I've tried this also, i've got the same error

My export code after update with Excel::MPDF, (Line 20)

Capture d’écran 2020-02-04 à 11 09 22

My laravel.log after update:

[2020-02-04 01:09:58] local.ERROR: No reader found for type Mpdf {"exception":"[object] (PhpOffice\\PhpSpreadsheet\\Reader\\Exception(code: 0): No reader found for type Mpdf at /home/vagrant/nautilus-africard/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php:71) [stacktrace] #0 /home/vagrant/nautilus-africard/vendor/maatwebsite/excel/src/Writer.php(110): PhpOffice\\PhpSpreadsheet\\IOFactory::createReader('Mpdf') #1 /home/vagrant/nautilus-africard/vendor/maatwebsite/excel/src/Jobs/AppendQueryToSheet.php(88): Maatwebsite\\Excel\\Writer->reopen(Object(Maatwebsite\\Excel\\Files\\RemoteTemporaryFile), 'Mpdf') #2 [internal function]: Maatwebsite\\Excel\\Jobs\\AppendQueryToSheet->handle(Object(Maatwebsite\\Excel\\Writer)) #3 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array) #4 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #5 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #6 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #7 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\\Container\\Container->call(Array) #8 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}(Object(Maatwebsite\\Excel\\Jobs\\AppendQueryToSheet)) #9 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Maatwebsite\\Excel\\Jobs\\AppendQueryToSheet)) #10 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #11 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\\Bus\\Dispatcher->dispatchNow(Object(Maatwebsite\\Excel\\Jobs\\AppendQueryToSheet), false) #12 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(88): Illuminate\\Queue\\CallQueuedHandler->call(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Array) #13 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(337): Illuminate\\Queue\\Jobs\\Job->fire() #14 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(283): Illuminate\\Queue\\Worker->process('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions)) #15 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), 'database', Object(Illuminate\\Queue\\WorkerOptions)) #16 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\\Queue\\Worker->daemon('database', 'exportation,def...', Object(Illuminate\\Queue\\WorkerOptions)) #17 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\\Queue\\Console\\WorkCommand->runWorker('database', 'exportation,def...') #18 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle() #19 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array) #20 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #21 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #22 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #23 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array) #24 /home/vagrant/nautilus-africard/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #25 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #26 /home/vagrant/nautilus-africard/vendor/symfony/console/Application.php(1012): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #27 /home/vagrant/nautilus-africard/vendor/symfony/console/Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #28 /home/vagrant/nautilus-africard/vendor/symfony/console/Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #29 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #30 /home/vagrant/nautilus-africard/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #31 /home/vagrant/nautilus-africard/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #32 {main} "}

@gordios
Copy link
Author

gordios commented Feb 12, 2020

Please, anyone can help me ?

@RobbeReygel
Copy link

I am having this exact issue (with Dompdf) and also can't find a solution. Could this be looked into?

(new InitiativeExportView($viewData))->store($fileName, 'public' , Excel::DOMPDF);

or when trying to chain jobs

(new InitiativeExportView($viewData))->queue($fileName, Excel::DOMPDF)->chain([ new NotifyUserOfCompletedExport($user, $fileName, $this->title), ]);

It seems there's something wrong with the way the package handles queue's specifically with Dompdf. Replacing the pdf with an xlsx does the job just fine.

@gordios
Copy link
Author

gordios commented Jun 26, 2020

@RobbeReygel Yes you're right. I think also this package seems stable only for "xlsx" exportation but not for PDF process. So PDF exportation should have another process. I suggest this package for PDF "mikehaertl/phpwkhtmltopdf". It works perfectly ! just read the docs and follow step !

@patrickbrouwers
Copy link
Member

@RobbeReygel @gordios the issue is that PhpSpreadsheet cannot re-open the spreadsheet if it's exported as Pdf. There's no reader for Pdf. When you use queue and the query gets chunked into multiple jobs, it indeed won't work.

You can prevent multiple queued chunks by using the WithCustomChunkSize and returning a high chunk size (higher than the max amount of rows you will export).

Alternatively you could drop the ShouldQueue interface and wrap the Excel::store in a Laravel job and queuing that one. That way your export is still queued, but won't chunk the queury.

As someone mentioned on the WIP 3.2 release, this issue is solved in 3.2 all together. #2575 (comment)

@stale
Copy link

stale bot commented May 31, 2021

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.

@stale stale bot closed this as completed May 31, 2021
@kskrlinnorth2
Copy link

2 years later and it still doesn't work with same error "No reader found for type Dompdf". Also there is no 3.2 version which, allegedly, solves this issue.

@kodunmi
Copy link

kodunmi commented Nov 8, 2023

3 years later and still same problem with DOMPDF

@feryardiant
Copy link

4 years later, someone else still experiencing this issue.

@SpartnerNL SpartnerNL locked and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants