sdglhm / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

message from webpage and no download dialogue #384

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.When creating a pdf using dompdf, the pdf gets created in the root directory, 
but I don't get a dialogue box with the open/save/cancel options. I also get a 
message from webpage box that displays what looks like the internal pdf code. I 
am testing this with IE8 and it also happens with Chrome. On a Windows 7 
machine. version 0.5.1 of dompdf

My php is as follows:

<?php
ini_set("memory_limit","24M");
session_start();
$recid = $_GET['recid'];
require_once 'fmview.php';
require_once 'FileMaker.php';
if (!isset($fm)){
    $fm = new FileMaker ();
    $fm->setProperty ( 'database', $_SESSION ['database'] );
    $fm->setProperty ( 'hostspec', $_SESSION ['hostname'] );
    $fm->setProperty ( 'username', $_SESSION ['username'] );
    $fm->setProperty ( 'password', $_SESSION ['password'] );
}
    $layout_object = $fm->getLayout ( 'SavedLetters' );
    $record = $fm->getRecordById ( 'SavedLetters', $recid );
$buff = htmlspecialchars_decode($record->getField( 'LetterTextCalc'));
include('dompdf/cppdf/dompdf_config.inc.php');
global $_dompdf_show_warnings;
global $_dompdf_debug;
global $_DOMPDF_DEBUG_TYPES;
$outfile = 'test.pdf';
$save_file = TRUE; // Save the file or not
$dompdf = new DOMPDF();
$dompdf->load_html($buff);
if ( isset($base_path) ) {
$dompdf->set_base_path($base_path);
}
$dompdf->render();  
if ( $_dompdf_show_warnings ) {
global $_dompdf_warnings;
foreach ($_dompdf_warnings as $msg) {
echo $msg . "\n";
}
echo $dompdf->get_canvas()->get_cpdf()->messages;
flush();
}
//
if ( $save_file ) {
if ( strtolower(DOMPDF_PDF_BACKEND) == "gd" ) {
$outfile = str_replace(".pdf", ".png", $outfile);
}
list($proto, $host, $path, $file) = explode_url($outfile);

if ( $proto != "" ) // i.e. not file://
$outfile = $file; // just save it locally, FIXME? could save it like wget: 
./host/basepath/file
$outfile = dompdf_realpath($outfile);
file_put_contents($outfile, $dompdf->output( array("compress" =>0) ));
            }
if (!headers_sent() ) 
ob_end_clean();                     
$dompdf->stream($outfile );
exit;
?>

Original issue reported on code.google.com by dloughli...@gmail.com on 28 Nov 2011 at 6:04

GoogleCodeExporter commented 9 years ago
It sounds like maybe the document is being sent. Maybe the headers are not set 
correctly.

Do you have a link to the problem page we can test? Or can you at least post a 
sample of what is displayed in the webpage box?

If you're still testing, it also may be worthwhile to try out the 0.6.0 code 
(still in beta, but fairly stable).

Original comment by eclecticgeek on 29 Nov 2011 at 6:48

GoogleCodeExporter commented 9 years ago
I have simplified my code, and it works great in IE8 (except need to figure how 
to deal with the multiple space issue). I get the download box, just as 
desired. The problem now is that when I do it in Chrome, I don't get the 
open/save/cancel dialog, but rather I just get the save dialog.
The current php script is:

<?php
ini_set("memory_limit","24M");
session_start();
$buff = $_GET['buff'];
include('dompdf/cppdf/dompdf_config.inc.php');

            $dompdf = new DOMPDF();
            $dompdf->load_html($buff);
            $dompdf->render();
            $dompdf->stream("test.pdf",array("Attachment" => 1));
        exit;
?>

Original comment by dloughli...@gmail.com on 30 Nov 2011 at 2:39

GoogleCodeExporter commented 9 years ago
Glad you were able to address your issue. Simplifying your code as much as 
possible always helps!

It looks to me that Chrome doesn't have an option to open a PDF rather than 
save it. So if you want it to display rather than download you'll have to set 
the attachment option to 0. The user can then manually save the PDF.

Ref:
http://www.google.com/support/forum/p/Chrome/thread?tid=1d571c09708dea01&hl=en
http://code.google.com/p/chromium/issues/detail?id=333

Original comment by eclecticgeek on 1 Dec 2011 at 7:07

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 30 May 2013 at 5:16