niklasravnsborg / laravel-pdf

📄 Laravel PDF
709 stars 209 forks source link

PDF load file does not return anything and gives 500 code instead #181

Open Andressu opened 3 years ago

Andressu commented 3 years ago

$file_name = str_replace('/','\', $material->video_path);

$config = ['instanceConfigurator' => function($mpdf) { $mpdf->SetWatermarkText('DRAFT'); $mpdf->showWatermarkText = true; }];

PDF::loadFile(storage_path('app\'.$file_name), $config);

Hi I want to watermark existing pdf File, but I have some issues.

When I had tried to debug the config parameter , it gave me this error

"message": "Allowed memory size of 536870912 bytes exhausted (tried to allocate 264245248 bytes)", "exception": "Symfony\Component\ErrorHandler\Error\FatalError", "file": "C:\inetpub\wwwroot\moodle_bridge-master\vendor\niklasravnsborg\laravel-pdf\src\LaravelPdf\PdfWrapper.php", "line": 28, "trace": []

But if don't do debug at all, it gives 500 code. It did not return any error. i was confused. What did I do wrong? Please help

niklasravnsborg commented 3 years ago

Hey! Can you try to load the pdf without modifying? Also did you try to increase your php memory size?

itzmj-23 commented 3 years ago

I have same concern.

$pdf = PDF::loadFile(public_path('myfile.pdf'));

When I visit the route of this, the browser keeps loading, until it gives error 500.

I am using:

Laravel 7.x PHP 7.4 "niklasravnsborg/laravel-pdf": "^4.1"

niklasravnsborg commented 3 years ago

Hey @itzmj-23,

what kind of error message or stack trace do you receive with the 500?