0

is there any way, to ope a pdf file in fpdf and return its content? This is my current code:

$pdf=new FPDF();
$pdf->Open();
var_dump($pdf); 

The var_dump() currently returns only document properties.

hakre
  • 193,403
  • 52
  • 435
  • 836
Laura
  • 1
  • 1
  • 1
  • What do you mean by "return its content"? In what form? How should formatting and images be dealt with? – Pekka Apr 28 '11 at 19:38
  • @Pekka It would be nice, if I coud echo the plain text, that I can work in it with php. Baout the images: currently I don't know...plain text would already be a big step forward.... – Laura Apr 28 '11 at 19:41
  • 1
    @Laura see e.g. [Read pdf files using php](http://stackoverflow.com/questions/4471274/read-pdf-files-using-php), especially the webcheatsheet link – Pekka Apr 28 '11 at 19:45
  • @Pekka ...I already tested this script and i returns nothing.... – Laura Apr 28 '11 at 19:55
  • ...it returns an empty array.... – Laura Apr 28 '11 at 20:05
  • Can you select/copy/paste the text in Reader? If not, then fpdf isn't going to do any better. – Mark Storer Apr 29 '11 at 00:31

1 Answers1

0

In case you want to create a preview image of your PDF file, download Ghostscript and ImageMagick. Install them as they are needed to create images. By the way, these applications may already be installed on your system (so check first).

Use the following PHP code to create preview images (200px wide) for all pages of your PDF file.

exec('convert "document.pdf" -colorspace RGB -geometry 200 "document.png"');

If you only want to create one preview image, use the following code. You may replace the number inside the square brackets by the desired page number starting at 0.

exec('convert "document.pdf[0]" -colorspace RGB -geometry 200 "document.png"');
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Fabianius
  • 695
  • 6
  • 13