Jump to content

How can I display a PDF file on screen?


DeX
Go to solution Solved by Jacques1,

Recommended Posts

I have a job management portal which I built and it allows my client to create PDF files of quotes for their customers. They send their customer a link (token based URL) so their customers can click the link and view the quote. I want to serve up the PDF file on screen for their customer to view, how can I do this? Each time I attempt it, Chrome asks me if I would like to download the file. I just want to view it without the customer having a direct link to it.

Link to comment
Share on other sites

  • Solution

The easiest option is to send the appropriate content type with header() and then show the file content with readfile().

<?php

header('Content-Type: application/pdf');

readfile('/path/to/pdf');

A more sophisticated and efficient approach is to delegate the file transfer to the webserver:

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.