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)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more