开发者

Retrieving images in the uploaded pdf document in php

开发者 https://www.devze.com 2023-03-25 06:33 出处:网络
I am trying to display the images in the pdf document that I uploaded to the server as hyperlinks in php so 开发者_JS百科that if user clicks on them they will get the corresponding document.

I am trying to display the images in the pdf document that I uploaded to the server as hyperlinks in php so 开发者_JS百科that if user clicks on them they will get the corresponding document.

Please help me ,Thanks in advance!


Use pdfimages, which comes with the open-source xpdf software package (for *nix operating systems). You'll have to call it through exec or the like, then work with the output from PHP. I am not aware of any PHP library that provides this functionality, so you're going to have to experiment.

EDIT

You mentioned that you aren't experienced with PHP... I thought I'd add that this isn't a quick-and-easy type of task, you certainly aren't going to find a bunch of tutorials around the internet for this.

To get started, you'll have to install the xpdf package on your server. There's a lot of different ways to do this depending on which OS you've got.

After that is set up, you'll be using a command line to execute a program on your server; you'll want to capture the output of that command in PHP and work with it further. So initially, you'll want to work out exactly what your command line will look like as well as what the output looks like and means - do this from command line, don't worry about the PHP part yet. In this case, your output is going to be a list of the image files extracted from a given PDF, you're command line call will look something like "pdfimages mypdf.pdf". Play around, find out what happens.

After you work out exactly what command line you need to send and what the command does, you can focus on the PHP angle. In a nutt shell, you want PHP to execute the exact command that you've already worked out. Look at the manual for exec for information on how to call a command line and get the output back. Write your script to make the correct call and show the call's output.

Next, move on to doing something with that output. I presume you'll want to somehow store the extracted images in a web-accessible place, put them in the database, show them to the user, etc. That is the very last stage after you've worked out the initial steps.

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消