In the document management system I am building, I needed to secure the pdf’s away from the browser so have them being uploaded to a folder called docs in the cgi-bin folder, works really well as nobody can access them throguh the browser.
But can someon give me some advice as to the process of allowing those pdf’s to be be display, I have read that you echo them out, but wondered if someone could give me the correct explanation for it so I can google it and try and work it out.
You have a logic error. Single quotes don’t expand. Though I’m having a hard time understanding why that line is there in the first place but we will go with it.
<?php
require_once('auth.php');
include "config.php";
error_reporting(E_ALL);
ini_set('display_errors','On');
if(isset($_GET['pdf']))
{
$stock_Id=$_GET['pdf'];
$q=mysql_query("select Document from Documents where ID=$stock_Id") or die (mysql_error());
$cdocdocb=$rows["Document"]; // cdocdocb - what does that even mean…
}
$file="$cdocdocb"; // Dont' understand why this is even here…
//header('Content-type: application/pdf');
//header('Content-Disposition: inline; filename="$file"');
//@readfile($file);
echo "<p>$file</p>";
?>
I changed it slightly to this on the error that came back, and it came back with the path to the pdf
<?php
require_once('auth.php');
include "config.php";
error_reporting(E_ALL);
ini_set('display_errors','On');
if(isset($_GET['pdf']))
{
$stock_Id=$_GET['pdf'];
$a=mysql_query("select Document from Documents where ID=$stock_Id") or die (mysql_error());
while($s=mysql_fetch_assoc($a)){
$cdocdocb=$s["Document"]; // cdocdocb - what does that even mean…
}
}
$file="$cdocdocb"; // Dont' understand why this is even here…
//header('Content-type: application/pdf');
//header('Content-Disposition: inline; filename="$file"');
//@readfile($file);
echo "<p>$file</p>";
?>
Hi again, am making sure I reply in this thread as is still on topic.
The pdf and everything above works fine, no worries there, but wondered if there anyway of having a small bit of html appear at the top of the page, so pushing the pdf down a bit to accomodate it.
Basically they wont to put a close button across the top of the page, and everything i try the html is ignored.
Something liek this I have been trying, but its not the way obviously, if it can be done at all i suppose.
<?php
session_start();
require_once('../auth.php');
include "../config.php";
error_reporting(E_ALL);
ini_set('display_errors','On');
if(isset($_GET['pdf']))
{
$stock_Id=$_GET['pdf'];
$a=mysql_query("select Document from Documents where ID=$stock_Id") or die (mysql_error());
while($s=mysql_fetch_assoc($a)){
$cdocdocb=$s["Document"]; // cdocdocb - what does that even mean…
}
}
$file="$cdocdocb"; // Dont' understand why this is even here…
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="$file"');
//@readfile($file);
echo "<div style='position:relative; width:100%; height:30px;'>123</div>";
echo "<p>"[EMAIL=".@readfile($file)."</p"].@readfile($file)."</p[/EMAIL]>";
?>
So now you need two scripts (or one script and some plain HTML).
The PDF script will be unchanged - the only difference is that you will need to reference it from an <object> or <img> tag from within the HTML that is providing the rest of the page content.
I’m sorry Im coming back to you but I just cant work out what you mean and cant find anything about it on the web to help me out, could you assist me a bit further with it.
Everything I try the pdf output overrides it and the pdf is displayed full page.
Im trying to basically have a div at the top of about 40px height, 100% width to allow me to put a close button in it.
I have made some progress, but this time the pdf isnt displaying, i get files does not begin with %pdf, so its nearly there, and this is what i got.
link from page calls html page
<body>
<div style="position:relative; width:100%; height:30px; background-color:#FF0000; margin-bottom:40px; clear:both;"></div>
<object data="spdf.php" type="application/pdf" width="100%" height="100%">
<p>It appears you don't have a PDF plugin for this browser.
No biggie... you can <a href="myfile.pdf">click here to
download the PDF file.</a></p>
</object>
</body>
</html>
Calling the page that creates the pdf
<?php
session_start();
require_once('../auth.php');
include "../config.php";
error_reporting(E_ALL);
ini_set('display_errors','On');
if(isset($_GET['pdf']))
{
$stock_Id=$_GET['pdf'];
$a=mysql_query("select Document from Documents where ID=$stock_Id") or die (mysql_error());
while($s=mysql_fetch_assoc($a)){
$cdocdocb=$s["Document"];
}
}
$file="$cdocdocb";
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="$file"');
@readfile($file);
//echo "<p>$file</p>";
?>
I thought something along these lines would cure it, but again the pdf when displayed takes over the full browser window, and no sign of any html.
<?php
session_start();
require_once('../auth.php');
include "../config.php";
error_reporting(E_ALL);
ini_set('display_errors','On');
if(isset($_GET['pdf']))
{
$stock_Id=$_GET['pdf'];
$a=mysql_query("select Document from Documents where ID=$stock_Id") or die (mysql_error());
while($s=mysql_fetch_assoc($a)){
$cdocdocb=$s["Document"];
}
}
$file="$cdocdocb";
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="$file"');
//@readfile($file);
//echo "<p>$file</p>";
?>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>utgroup admin</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-type" />
</head>
<body>
<div style="position:relative; width:100%; height:30px; background-color:#FF0000; margin-bottom:40px; clear:both;"></div>
<object data="<?php echo @readfile($file);?>" type="application/pdf" width="100%" height="100%">
<p>It appears you don't have a PDF plugin for this browser. No biggie... you can <a href="myfile.pdf">click here to download the PDF file.</a></p>
</object>
</body>
</html>