skip to Main Content

I am looking for a way to print a PDF file in my laravel application. I have only found on the internet solutions to print the PDF in the web browser. Is there a package that allows me to view a PDF directly in a native Control webBrowser? Thanks in advance!

2

Answers


  1. https://github.com/niklasravnsborg/laravel-pdf

    This package allows you to use the "stream" function to return the pdf back to the browser without downloading it.

    Login or Signup to reply.
  2. If you just need to output the pdf directly in the browser – and not referring to a pdf generation library – you can output the correct pdf headers and then print the file.

    for example, see this code snippet:

    $file = 'filename.pdf';
    $filename = 'filename.pdf';
    
    header('Content-type: application/pdf');
    header('Content-Disposition: inline; filename="' . $filename . '"');
    header('Content-Transfer-Encoding: binary');
    header('Accept-Ranges: bytes');
    
    @readfile($file);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search