-->

Why is my code getting an error of Fatal error: Un

2019-07-17 01:34发布

问题:

When the records are many and it needs to be print on second page of the pdf I have encounter this error

Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'Frame not found in cellmap' in C:\xampp\htdocs\pdf_dompdf\dompdf\include\cellmap.cls.php:244 Stack trace: #0 C:\xampp\htdocs\pdf_dompdf\dompdf\include\table_cell_renderer.cls.php(50): Cellmap->get_spanned_cells(Object(Table_Cell_Frame_Decorator)) #1 C:\xampp\htdocs\pdf_dompdf\dompdf\include\renderer.cls.php(287): Table_Cell_Renderer->render(Object(Table_Cell_Frame_Decorator)) #2 C:\xampp\htdocs\pdf_dompdf\dompdf\include\renderer.cls.php(107): Renderer->_render_frame('table-cell', Object(Table_Cell_Frame_Decorator)) #3 C:\xampp\htdocs\pdf_dompdf\dompdf\include\renderer.cls.php(190): Renderer->render(Object(Table_Cell_Frame_Decorator)) #4 C:\xampp\htdocs\pdf_dompdf\dompdf\include\renderer.cls.php(190): Renderer->render(Object(Table_Row_Frame_Decorator)) #5 C:\xampp\htdocs\pdf_dompdf\dompdf\include\renderer.cls.php(190): Renderer->render(Object(Table_Row_Group_Frame_Decorator)) #6 C:\xampp\htdocs\pdf_dompdf\dompdf\include\renderer.cls.php(190): Renderer->render in C:\xampp\htdocs\pdf_dompdf\dompdf\include\cellmap.cls.php on line 244

 <div class="ORMExSum">
    <h1 align="center">ORM Executive Summary Report</h1>
      <table cellpadding="0" cellspacing="0" border="1" width="100%">
      <caption style="text-align:left; padding-bottom: 10px;">Keyword: <?php echo 'Juan dela Cruz, Juan Cruz'; ?></caption>
        <thead class="theader">
          <tr><th colspan="<?php echo 3+$rtweekly; ?>">Weekly Rankings</th></tr>
          <tr>
          <th width="10%">Location</th>
          <th width="40%">Negative Snippet</th>
          <th width="10%">Previous Ranking</th>
          <?php while($rw1<$rtweekly):  ?>
            <th width="8%">
            <?php echo date('M. d', strtotime (mysql_result($tweekly,$rw1,"WeeklyRank"))); $rw1++; ?>
            </th>
          <?php endwhile; ?>
          </tr>
         </thead>

         <tbody> 
          <?php $x='a';while($rw2<$rsummary): $rw3 = 0;?>
          <tr>
          <td rowspan="<?php echo $cnt[$x]+1;$x++;?>">
          <?php echo mysql_result($summary,$rw2,"Location");  ?>
          </td>
          <?php for ($i=0; $i < 2+$rtweekly; $i++): ?>
          <td></td>
          <?php $cnt++; endfor;?>
          </tr>

            <?php while($rw3<$rsnippet): $rw4 = 0;?>

              <?php if(mysql_result($snippet,$rw3,"SummaryID") == mysql_result($summary,$rw2,"LocationID")): ?>
                <tr>
                <td style="font-size:11px;">
                <?php echo mysql_result($snippet,$rw3,"NegativeSnippet"); ?>
                </td>
                <td>
                <?php echo mysql_result($snippet,$rw3,"PreviousRank"); ?>
                </td>
                <?php while($rw4<$rtweekly): $rw5 = 0;?>
                <td>
                <?php while($rw5<$rweekly): ?>
                  <?php if(mysql_result($weekly,$rw5,"SummaryID") ==  mysql_result($summary,$rw2,"LocationID") && mysql_result($weekly,$rw5,"SnipPrevID") == mysql_result($snippet,$rw3,"NSPID") && mysql_result($tweekly,$rw4,"WeeklyRank") == mysql_result($weekly,$rw5,"WeeklyRank")): ?>
                  <?php echo mysql_result($weekly,$rw5,"Rank"); ?>
                  <?php endif;?>
                <?php $rw5++; endwhile; ?>
                </td>
                <?php $rw4++; endwhile; ?>

              <?php endif;?>
              </tr>
            <?php $rw3++; endwhile; ?>

            <?php $rw2++; endwhile; ?>


        </tbody>
      </table>
      </div>

回答1:

I had the same issues.

I've fix it with X row.. force to break-page.

it's just because the pdf try to output a lot of row and he can't jump to the next page.

In your case, try to place an :

 page-break-after: always;

on the first tr..

<tbody> 
      <?php $x='a';while($rw2<$rsummary): $rw3 = 0;?>
      <tr style="page-break-after: always;">

or you can make a php to do that after X line.

I hope that will be useful for someone.

Best regards,

===== EDIT =====

Also, remove the "border-collapse" on your table.



回答2:

This happens when a table extends beyond the size of the paper.
You can use a custom paper size. It will solve the problem.

Example :

$paper_orientation = 'landscape';
$customPaper = array(0,0,950,950);
$dompdf->set_paper($customPaper,$paper_orientation);


回答3:

I have been facing the same problem for days, in a huge table with rowspan and colspan, but no border-collapse:collapse (there is a known issue related to that property).

I have resolved it by adding this to the style of my table element:

table
{
   border-collapse:unset;   
}

Hope it helps!



回答4:

I had the same issues. Make sure you don't have any external css or any other linked file. However i fixed it by completely designing the PDF file through internal css and inline css. I hope it solve your problem.



回答5:

This could be solved when closing the tables several times. Then tables fits to the paper size ant the error is gone.



标签: php html5 dompdf