Home >>PHP Programs >PHP Read Pdf file

PHP Read Pdf file

Read Pdf file in PHP

This Tutorial Provides you easy steps to read PDF file in PHP. Read PDF file and show the contents of the file on browser. First You have to include an external PHP file named "class.pdf2text.php". Create a HTML form, from where u can choose your pdf file from any location. Check Whether file extension is pdf or not.

HTML Form(choose pdf file)

		<title>Read pdf php</title>
	<form method="post" enctype="multipart/form-data">
		<table align="center" border="1" bgcolor="#CCCCCC">
				<td>Choose Your File</td>
				<td><input type="file" name="file"/></td>
				<td align="center" colspan="2"><input type="submit" value="Read PDF" name="readpdf"/></td>

PHP Script(check file extension is pdf then read the contents and display the contents on browser)

//first include an external class.
	//check the types of file
	$a = new PDF2Text();
	echo $a->output(); 
	//if file types is not pdf
	echo "<p style='color:red;text-align:center'>Wrong file format </p>";


No Sidebar ads