ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

DOMPDF Problem

January 20, 2010 9:52am

Subscribe [2]
  • #1 / Jan 20, 2010 9:52am

    aruntvla

    12 posts

    when using dompdf it showing the following error….......

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Division by zero
    
    Filename: lib/class.pdf.php
    
    Line Number: 4664
    
    
    Unable to stream pdf: headers already sent

    How to solve this one…please reply??????

     

    My View page

    <html>
    <head>
    <title>Untitled Document</title>
    <style type="text/css">
    .style2 {
        font-size: 24px;
        color: #FFFFFF;
    }
    .style4 {
        font-size: 24px;
        font-weight: bold;
    }
    .style5 {font-size: 24px; font-weight: bold; color: #FFFFFF; }
    </style>
    </head>
    <body>
    <table width="595" height="842" border="1" cellpadding="0" cellspacing="0" align="center">
     <tr>
            <td height="83" bgcolor="#A42A2A"><span class="style4"> 
         </span>
         <div align="center" class="style5">Logo</div></td>
      </tr>
       <tr>
        <td height="83" bgcolor="#A42A2A"><span class="style4"> 
         </span>
         <div align="center" class="style5">Coupons</div></td>
      </tr>
    <?php 
    if(isset($coupondetail))
    {   
    for($i=0;$i<count($coupondetail);$i++)
    { 
    ?>
    <tr>
    <td> <img >photo ; ?>" border="0"  108%;"></td>
    </tr><?php }} ?>
    </table>
    </body>
    </html>
  • #2 / Jan 20, 2010 1:34pm

    danmontgomery

    1802 posts

    <img >photo ; ?>

    Post code relevant to the error, the lines where you are calling the dompdf code and line 4664 of class.pdf.php

  • #3 / Jan 21, 2010 12:21am

    aruntvla

    12 posts

    *************to_pdf_pi.php*************************

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    function pdf_create($html, $filename, $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 {
            $CI =& get_instance();
            $CI->load->helper('file');
            write_file("./invoices_temp/invoice_$filename.pdf", $dompdf->output());
        }
    }
    ?>

    **************************************************************

                          Controller page function

    function pdf()
    {
         $this->load->plugin('to_pdf');
         // page info here, db calls, etc.     
         $html = $this->load->view('user_printpreview', $this->data, true);
         pdf_create($html, 'coupon');
    }

    *********************************************************************

                    View Page

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    .style2 {
        font-size: 24px;
        color: #FFFFFF;
    }
    .style4 {
        font-size: 24px;
        font-weight: bold;
    }
    .style5 {font-size: 24px; font-weight: bold; color: #FFFFFF; }
    -->
    </style>
    </head>
    <body>
    <table width="595" height="842" border="1" cellpadding="0" cellspacing="0" align="center">
     <tr>
            <td height="83" bgcolor="#A42A2A"><span class="style4"> 
         </span>
         <div align="center" class="style5">Logo</div></td>
      </tr>
       <tr>
        <td height="83" bgcolor="#A42A2A"><span class="style4"> 
         </span>
         <div align="center" class="style5">Coupons</div></td>
      </tr>
    <?php 
    if(isset($coupondetail))
    {   
             for($i=0;$i<count($coupondetail);$i++)
                        { ?>
      <tr>
        <td> <img >photo ; ?>" border="0"  108%;"></td>
      </tr>
    <?php }} ?>
    </table>
    </body>
    </html>


    Error in Localhost : Broken mesages showing in pdf file

    Error in server :

    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Division by zero
    
    Filename: include/image_frame_reflower.cls.php
    
    Line Number: 89
    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Division by zero
    
    Filename: lib/class.pdf.php
    
    Line Number: 4659


    Please give me a suggestion??????????

  • #4 / Jan 21, 2010 1:02am

    John Pantoja

    49 posts

    Only Tom Cruise can divide by zero! 😊

    I haven’t played with DOMPDF in a minute, but what I do recall, it didn’t like something with certain styling information. Try pulling out all of your embedded stuff and your css, format with just regular html tags (
    , ) and see if it spits out anything. Also I think you need to do a string count or something with stream (or I might be thinking of something else) and pass it along as I think it added the Content-length: header.

  • #5 / Jan 21, 2010 7:59am

    aruntvla

    12 posts

    Thanks Noctrum & John Pantoja , atlast i found it..wre is the problem???
    when uploading images i named it with vendorname.jpg,here vendorname taken from input field…my tested image contains name as
                   
                        galtech enterprises.jpg [space is the error reason]

    <img >photo ; ?>" border="0"  108%;">

    actual line is filtered there is image source from my server…...

    so it shows error in this line…...thanks friends…..

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases