"visibility:hidden;" is not working with TCPDF

时间:2016-04-25 09:40:42

标签: php html css pdf tcpdf

I just try to HTML to PDF with TCPDF

but something is wrong

The CSS visibility Property is not working to me

this is my php code:

<?php

Include the main TCPDF library (search for installation path).

require_once('tcpdf_include.php');

create new PDF document

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

set document information

$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 061');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 061', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('helvetica', '', 10);

// add a page
$pdf->AddPage();
$html = <<<EOF

//HTML code

EOF;

// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// reset pointer to the last page
$pdf->lastPage();

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('example_061.pdf', 'I');

this is my html code

 <!-- EXAMPLE OF CSS STYLE -->
      <!DOCTYPE HTML>
      <style>
        table{
            border:1px solid #C0C0C0;
            border-collapse:collapse;

        }
        tr{ 
        }
        td {
            border:1px solid #C0C0C0; 

        }

    </style> 

    <table  id="BA1">
    <tr style=" visibility:hidden;"  >
    <td height= "1" ></td>
    <td height= "1"  class="ui-resizable" style="width: 39px;"></td>
    <td height= "1"  class="ui-resizable" style="width: 76px;"></td>        
    <td height= "1"  class="ui-resizable" style="width: 33px;"></td>
    <td height= "1"  class="ui-resizable" style="width: 132px;"></td>
    <td height= "1"  class="ui-resizable" style="width: 345px;"></td>
    </tr>   
    <tr><td class="ui-resizable" style="height: 10px; visibility: hidden;"> </td>       
    <td class="" style=" font-size: 10px;">編號</td>
    <td></td>
    <td class="" style="font-size: 10px;">姓名</td>
    <td></td><td class="" style=" font-size: 10px;">公布欄</td></tr>
    <tr><td class="ui-resizable" style="height: 10px; visibility: hidden;"></td>
    <td colspan="3" rowspan="1" class="" style=" font-size: 10px;">繳費項目</td>    <td class="" style="font-size: 10px;">金額</td><td colspan="1" rowspan="2"></td></tr>     
    <tr><td class="ui-resizable" style="height: 134px; visibility: hidden;"></td>       
    <td colspan="4" rowspan="2"></td></tr>  
    <tr><td class="ui-resizable" style="height: 92px; visibility: hidden;"></td>
    <td colspan="1" rowspan="2"></td></tr>
    <tr><td class="ui-resizable" style="height: 17px; visibility: hidden;"></td>
    <td colspan="4" rowspan="1" class="" style=" font-size: 10px;">合計:</td></tr></table>

If do not support this property

There is no other way recommended?

1 个答案:

答案 0 :(得分:1)

TCPDF extension has a very little css support.

Currently, only the following CSS attributes are supported:

  • font-family
  • font-size
  • font-weight
  • font-style
  • color
  • background-color
  • text-decoration
  • width
  • height
  • text-align

Other tags will not work.