FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Search PDF document from PHP





bukaida
Is it possible to open a pdf page in a pdf document based on a search key supplied from php/html?
I have tried with
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <title>PDF opener</title>
</head>

<body>
<A HREF="http://localhost/pdftest/xyz.pdf#search=abcdef"> Search</a>


</body>
</html>


But it is opening the document from the first page.Changing it to #page=4 also has no effect.
johnsworthy
Might not work with all different pdf readers. Look up the API for Adobe:s PDF plugin. But as I said, it might not work on other plugins, and not for OS X / *nix users.
jmraker
I've never heard of using <a href="file.php#searchText"> as a way to open the pdf file to the page with the first use of a search term. The text after a # is usually a reference to the "thisText" in <a name="thisText" />

If there is such a feature it might be "file.php?q=searchText" but I doubt plugins will take any parameters.

The most likely approach would be to use javascript which knowing adobe would be buried under mountains of documentation.
http://www.adobe.com/devnet/acrobat/javascript.html

--
Edit: Oops, I meant file.pdf#searchText in the 2 places above
bukaida
jmraker wrote:
I've never heard of using <a href="file.php#searchText"> as a way to open the pdf file to the page with the first use of a search term. The text after a # is usually a reference to the "thisText" in <a name="thisText" />



I have not made any attempt to open a file with php extension. My file extension is .pdf and the syntax is as per Adobe API Reference.
jmraker
According to that document it would be http://example.org/doc.pdf#search=wordList and must be enclosed in quotes.

You can try using quotes like
<a href="http://localhost/pdftest/xyz.pdf#search=&quot;abcdef&quot;">Search</a>
or
<a href='http://localhost/pdftest/xyz.pdf#search="abcdef"'>Search</a>

Do you know if the document applies to the Acrobat reader plugin? It might be just for Acrobat, their program that creates pdf files.
Fire Boar
Actually I think the correct format is

Code:
<a href="http://example.com/path/to/file.pdf#search=%22term%22">Search</a>


%22 is the url-encoded form of the double-quote ("). You should never use single quotes in an HTML parameter.
bukaida
Thanx to both of you. Is it possible to use $var in the search term where $var is coming from a php form? I mean something like--

Code:

<a href="http://example.com/path/to/file.pdf#search=%22$var%22">Search</a>
jmraker
Yes php can replace $var. It can do it inside a double quoted string. If you prefer using single quoted strings it won't work until unless you concatenate it as in
echo '<a href="http://example.com/path/to/file.pdf#search=%22' . $var . '%22">Search</a>';

If it's not in a <?php ?> block you'll have to use
<a href="http://example.com/path/to/file.pdf#search=%22<?=$var?>%22">Search</a>
or
<a href="http://example.com/path/to/file.pdf#search=%22<?php echo $var;?>%22">Search</a>
bukaida
Got the idea, thanx.
Radar
If you ever feel like going the other way and writing PDFs with PHP, I highly recommend FPDF. A nicely done piece of code, and allows you to structure the code to generate your page in several ways.
bukaida
Quote:

If you ever feel like going the other way and writing PDFs with PHP, I highly recommend FPDF. A nicely done piece of code, and allows you to structure the code to generate your page in several ways.


I already have the pdf files and their text equivalents.The text files are stored in mysql and the full text search is performed there.As the structure of the text cannot be retained in plain text, so I want to go to the same place in the PDF files for which I got the result in php.This can be done by supplying the id/name and the key to the same file(pdf version) from php.
bukaida
Sorry to inform that even the open particular page via URL is not working with me. I have adobe 9.4 reader on windows XP pro. I am following their documentation as specified by

http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf

but the pdf is opening always with the first page. i.e.
Code:
<a href="test.pdf#page=3">Open PDF</a>
is opening the document with page one and not 3. Is there some problem with my local system or plugins?
Related topics
A "small" list of free apps
Make search engine With PHP and mySQL, for your site
convert ur PDF files to word documents
Programming links, info, and tutorials
Digital Archive
A problem printing a PDF document
Creating a Search Script with PHP for MySQL
Need help with a HTML / PHP question.
Refine Search
php/sql question
need a software for converting pdf to word (FREE)
How to convert document to text without printing/scanning?
PDF with PHP
problem in validating signature of a pdf document
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.