DEV Community

Davronbek
Davronbek

Posted on

PHP/Laravel: <embed> cannot display 30MB+ PDF file

Hi folks!

If I pass the direct url to the PDF file, can display large PDF file, but if I generate preview url for that file, and in that preview page return the PDF file content, cannot display it, showing error:

Failed to load PDF document

preview page (Laravel):

public function preview(Request $request) {
  $pdfFileContent = $this->storage->getFileContent($request->uuid);
  return response()->make($pdfFileContent, 200, [
         'Content-Type' => 'application/pdf',
         'Content-Disposition' => 'inline',
  ])
}
Enter fullscreen mode Exit fullscreen mode

view PDF:

<embed src="/file/preview/{uuid}" width="100%" height="800" type="application/pdf"></embed>
Enter fullscreen mode Exit fullscreen mode

Any help would be appreciated! Thanks beforehand!

Top comments (0)