Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

table width 100% doesn't work #532

Mr-TOA opened this issue Jan 3, 2020 · 0 comments

table width 100% doesn't work #532

Mr-TOA opened this issue Jan 3, 2020 · 0 comments


Copy link

@Mr-TOA Mr-TOA commented Jan 3, 2020

is there anyway that i can fit the table to the page (A4), it's a dynamic table
the table picture
none of below worked

<table width="100%">
<table style="width:100%;">
<table class="w100">
<link rel="stylesheet" href="style.css" />

my code:

$content = '<table>
            <th class="bg-dark text-white" align="center">#</th>
            <th align="center" class="bg-dark text-white">Code</th>
            <th align="left" class="bg-dark text-white">Description</th>
            <th align="center" class="bg-dark text-white">Item Type</th>
        <tr style="background-color: #f2f2f2;">
            <td align="center">1</td>
            <td align="center">1001</td>
            <td align="left">Pofak</td>
            <td align="center">Fixed Price</td>
            <td align="center">2</td>
            <td align="center">1002</td>
            <td align="left">Ice</td>
            <td align="center">Weight</td>
        <tr style="background-color: #f2f2f2;">
            <td align="center">3</td>
            <td align="center">1003</td>
            <td align="left">Minoo</td>
            <td align="center">Fixed Price</td>
$newContent = '
    <style type="text/css">
    table, table td, table th{
        border-collapse: collapse;
        border: solid 1px #ababab;
    .text-dark, table td{
        color: #343a40;
        color: #ffffff;
    table td,
    table th {
        font-size: 11px;
        padding: 3px;
        line-height: 1.2;

    .bg-dark {
        background-color: #343a40;
    .bg-secondary {
        background-color: #6c757d;
    .bg-white {
        background-color: #ffffff;
    .text-left {
        text-align: left;
    .text-right {
        text-align: right;
    .text-center {
        text-align: center;
    $newContent .= '<page>'.$content.'</page>';

    try {
        $html2pdf = new Html2Pdf('P', 'A4', 'en', true, 'UTF-8', 5);
        $PDFName = "ItemLists_".date('Y.m.d_H.i.s').".pdf";
        $html2pdf->output($PDFName, 'I');
    } catch (Html2PdfException $x) {

        $formatter = new ExceptionFormatter($x);
        echo $formatter->getHtmlMessage();

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.