Asked By
Jeremy Jack
30 points
N/A
Posted on - 11/02/2012
Hello friends,
What is the php codes to open a pdf online? I was on the process of building my webpage about online storage upload such as word documents, pdf files and more. I am on the part which allows the user to open a specific file called pdf. I need some help.
Thanks and Regards,
Jeremy Jack.
What is the php codes to open a PDF online?
PhP is sever site language. PhP normally use in creation of dynamic websites. PhP have many functions related with PDF files but first of all you need to install PDFlib on you web server. If you have no access than contact your website admin and tell him to this.
Follow these steps
Download PDFlib from PDFlib.com only for personal use. If you have commercial website buy this product. Install PDFlib in your root directory.
Open the require page you want to open add this
“int PDF_open_pdi(resource $pdfdoc, string $filename, string $optlist, int $len)."
Â
Write down your filename and location in this function. Save your page and run.
What is the php codes to open a PDF online?
Hi,
There are many ways to open pdf online.
Use below code in your php file and run it in localhost.
<?php
$file = 'serverStartup.pdf'; // Here give your PDF file name.
$filename = 'Custom file name for the.pdf'; /* Note: Always use .pdf at the end. */
Â
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
Â
@readfile($file);
?>
It will display outlook as following.