1

I want to read the pdf documents and display the content to the browser, without allowing the users to save a copy of the pdf.

How can i use fpdf for this purpose? So far, i could not figure out a way of reading a pdf document with fpdf, apart from creating a new pdf. Can anyone suggest an example of reading a pdf file, and if possible, how to disable the save as pdf option?

5
  • 2
    You want to serve the file as PDF? Or convert it to HTML, so the user won't get the original PDF? Either way, the user can always save something. You're sending data to the user's computer, you have no control over what he does with it! Commented Jan 13, 2011 at 9:32
  • Yes, i do agree. But what i want is to be able to read a pdf and convert it to html for displaying in the browser. How to achieve this? Commented Jan 13, 2011 at 9:35
  • Then you should make clear in your question that you're trying to convert a PDF to HTML. You won't be able to disable the "Save as PDF" option though. Commented Jan 13, 2011 at 9:37
  • 1
    Have you consider converting pdf pages to images and send that to browser. And yes, that way user can save images and make a pdf with them but not your original pdf. Is that acceptable to you? if that is acceptable you can use Imagemagick or/and Ghostcript to make images. Commented Jan 13, 2011 at 9:40
  • Hope this solution will fit my needs. Much better. Commented Jan 13, 2011 at 10:01

4 Answers 4

2

fpdf can't read pdf's. take a look at it's FAQ - 16 an 17 sound interesting and it loooks like there are addons to do this.

what you really can't ever avoid is to let the user save that pdf - it has to be sent to the browser at the clients machine, to display it, so there will always be a possibility to save it. a possibility would be to transform every page of the pdf to an image (using Imagemagick for example) and oly display these images, so the user can't copy the text from it and has no possibility to get the original pdf-document - but that will only annoy people.

Sign up to request clarification or add additional context in comments.

Comments

0

If you have an existing PDF you want to display it inline rather than ask them to download it:

// Path to PDF file
$file = "blah.pdf";

// Show in browser
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit();

You don't need to use FPDF that's only a class that helps you create PDF's from scratch.

Also bare in mind there is nothing to stop a user from saving a PDF even when displaying inline.

1 Comment

oh... probably you did not get my question right... i have edited it now.... what i wanted is that the users must be able to read the content of a pdf document. That means, the document already exists... i just want to convert it to html and display to the users.
0

Im not sure if this is possible, check the FPDI extension for FPDF here: http://www.setasign.de/products/pdf-php-solutions/fpdi/

Comments

0

To convert a pdf to html there a program for linux called pdftohtml. However be aware that the result of this will not create something that looks like the original pdf and in many cases (locked pdf's etc) it will fail. What is a possible solution is generating an image of each page using a program like ImageMagick, then place the html over on an invisible layer to allow for interaction. I'd still rather go for displaying the pdf inline if I were you though.

1 Comment

Is there any example for windows version of converting a pdf to image (either entire pdf, or one page at a time), using imagemagick and ghostscript ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.