Welcome Guest, Not a member yet? Register   Sign In
Error DOMPDF
#1

[eluser]SteelSeriesX[/eluser]
I am trying to create a php page that generates as a pdf file.
Some code I have riped from this forum, to test if it works. In my code I can't find any white spaces infront or behind of the <?php ?> what is the solution that is given at many topics.

I am getting this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: _dompdf_show_warnings

Filename: include/dompdf.cls.php

Line Number: 530
Unable to stream pdf: headers already sent


The files I use:

View (pdf_view.php)
Code:
<html>
<head>
        <title>PDF Sample</title>
        <?php
        if ( isset($pdf) ) {
            //This goes to the header
            $font = Font_Metrics::get_font("Helvetica", "bold");
            $pdf->page_text(72, 18, "Page {PAGE_NUM} of {PAGE_COUNT}", $font, 8, array(0,0,0));

            //get started with the footer
            // Open the object: all drawing commands will
            // go to the object instead of the current page
            $footer = $pdf->open_object();
            $text_height = 7;

            $w = $pdf->get_width();
            $h = $pdf->get_height();
            $y = $h - 2 * $text_height - 24;
            $size = 7;
            $color = array(255,255,255);

            $font = Font_Metrics::get_font("Helvetica", "italic");
            $text = "http://www.ikawka.com/ - ".date("F m, Y - h:i:s a");
            $width = Font_Metrics::get_text_width($text, $font, $size);

            // Add a logo
            $img_w = 540; // 2 inches, in points
            $img_h = 20; // 1 inch, in points -- change these as required

            $pdf->image("images/logo.png", "png", ($w - $img_w) / 2.0, $y - $img_h, $img_w, $img_h );
            $pdf->text(38, $y-16, $text, $font, $size, $color);
            // Close the object (stop capture)
            $pdf->close_object();

            // Add the object to every page. You can
            // also specify "odd" or "even"
            $pdf->add_object($footer, "all");
        }?>
    </head>
    <body>
        <h1>Hello Gallaxy!!!</h1>
    &lt;/body&gt;
&lt;/html&gt;

Plug-in (to_pdf_pi.php)
Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

    function pdf_create($html, $filename, $path = '', $stream = TRUE)
    {
        require_once("dompdf/dompdf_config.inc.php");

        $dompdf = new DOMPDF();
        $dompdf->load_html($html);
        $dompdf->render();

        if ($stream)
        {
            $dompdf->stream($filename . '.pdf');
        }
        else
        {
            write_file($path . $filename . '.pdf', $dompdf->output());
        }
    }

Controller (showpdf.php)
Code:
&lt;?php
class Showpdf extends Controller
{
    function pdf()
    {
         $this->load->plugin('to_pdf');
        $html = $this->load->view('pdf_view','lol',TRUE);
        pdf_create($html,'filename');
    }
}
?&gt;

Please help me solve this problem Smile
#2

[eluser]webnology[/eluser]
Check if you have no spaces or anything bedore the &lt;?php... That's my first wild guess here.

CHeers,
M
#3

[eluser]SteelSeriesX[/eluser]
I checked all, but there is non
#4

[eluser]Unknown[/eluser]
If you are still having issues, you could try posting on our Google Groups for some help with DOMPDF.
www.dompdf.com
#5

[eluser]Cro_Crx[/eluser]
I'm having the same problems. The script was taking up all of PHP's allocated RAM (only 8MB) so I bumped it up. Now I'm receiving the same error as the OP.

UPDATE: I upgraded my dompdf to version 0.5.2 from this website ==> http://digitaljunkies.ca/dompdf/ and it seems to be working fine now.
#6

[eluser]CARP[/eluser]
@SteelSeriesX did you solve it?
@Cro_Crx the 0.5.2 version isn't available.

I've got the 0.6.0_alpha2, which gives the error. Tried with 0.5.1, but never finishes loading anything
http://code.google.com/p/dompdf/downloads/list

PS: also checked for whitespaces at beginning and end of to_pdf_pi.php, controller, view, etc.




Theme © iAndrew 2016 - Forum software by © MyBB