What is the php codes to open a PDF online?

Asked By 30 points N/A Posted on -
qa-featured

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.

SHARE
Answered By 0 points N/A #185449

What is the php codes to open a PDF online?

qa-featured

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.

Answered By 0 points N/A #185450

What is the php codes to open a PDF online?

qa-featured

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.

Login/Register to Answer

Related Questions