Sending PDF password via php
Posted: Wed Sep 21, 2011 11:38 am
Hi All
I have been struggling with this for a while. On my intranet site I create PDF's, and assign them a password (they all have the same password). Now i want to know if there's a method to send the pdf document the password via php? I assume it would be done here:
The reason why I need the php to send the password is because when users open the file using the intranet, they should be allowed to see it automatically as they are already logged in. A person who finds the document on the server, for example, would have to type in the password manually to get access to the document.
I have been struggling with this for a while. On my intranet site I create PDF's, and assign them a password (they all have the same password). Now i want to know if there's a method to send the pdf document the password via php? I assume it would be done here:
Code: Select all
$file = "../../../base/ScanReport.pdf";
if (file_exists($file))
{
header('Content-Description: File Transfer');
header('Content-Type: MIME');
header('Content-Disposition: inline; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
else
{
echo "<font color = 'red'>Something went wrong, file not created.</font>";
}