Show pdf in a browser window

12 views
Skip to first unread message

Francesco Pepe

unread,
Jan 22, 2014, 10:42:38 AM1/22/14
to purepdf...@googlegroups.com
I'd like to show my pdf in a browser window instead of downloading it.

I've tried with this code:

var urlRequest:URLRequest = new URLRequest("http://myserver.com/pdf.php?name=test.pdf&download=inline");
urlRequest.method = URLRequestMethod.POST;
urlRequest.data = buffer;
navigateToURL(urlRequest);

In my pdf.php script I have the following code:

<?php
 
$method = $_GET['download'];
$name = $_GET['name'];
 
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
 
// get bytearray
$pdf = $GLOBALS["HTTP_RAW_POST_DATA"];
 
// add headers for download dialog-box
header('Content-Type: application/pdf');
header('Content-Length: '.strlen($pdf));
header('Content-disposition:'.$method.'; filename="'.$name.'"');
echo $pdf;
 
}  else echo 'An error occured.';
 
?>

However php output the error string: "An error occured"

Could someone help me? is there a server side script that I could use?
Reply all
Reply to author
Forward
0 new messages