Forum


Replies: 3   Views: 5950
Pdf table width columns
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by magira  · 15-02-2016 - 16:43

Hello team !

Today, I've upgrade my corporate version from 4.1 to 5.5.

I have performed some test, and i found a difference with the width of table columns.Indeed, with the new version it has all the same size.

I'm sure I performed the same tests on the environment by simply changing the version number of the library called.

require_once '../../library/phpdocx/classes/CreateDocx.inc';

to 

require_once '../../library/phpdocx5/classes/CreateDocx.inc';


For information, 

PHP_VERSION: 5.3.19
PHP_OS: WINNT
PHP_UNAME: Windows NT PINATUBO 6.1 build 7601 (Windows 7 Business Edition Service Pack 1) i586
SERVER_NAME: oih_trunk.local
SERVER_SOFTWARE: Apache/2.2.22 (Win32) PHP/5.3.19
SERVER_ADDR: 127.0.0.1
SERVER_PROTOCOL: HTTP/1.1
HTTP_HOST: oih_trunk.local
HTTP_X_FORWARDED_FOR: 
PHP_SELF: /library/phpdocx/check.php
XSLTProcessor: 1
ZipArchive: 1
DomDocument: 1
SimpleXMLElement: 1
Tidy: 1

You can see my test result by downloading files : here

Posted by admin  · 15-02-2016 - 19:47

Hello,

You need to set the table and td widths if you don't want the default size. And if you're working with the conversion plugin to generate PDFs, we recommend you to use the plugin that uses LibreOffice instead of OpenOffice.

Regards.

Posted by magira  · 16-02-2016 - 08:16

Hello, I allready set the table and td width. Look my executed code : 

$docx = new CreateDocx();

$html='
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
                <title>Title of the document</title>
                
                <style type="text/css">
                        table {border: 1px solid green; }
                        table, tr, td {padding : 15px;}
                </style>
        </head>
        <body>
                <table width="475px">
                        <colgroup>
                                <col width="75" style="background-color:red; width:75px;">
                                <col width="400" style="background-color:yellow; width:400px;">
                        </colgroup>
                        <tr>
                        <td width="75" style="width:75px;">Cell 1 1</td>
                        <td width="400" style="width:400px;">Cell 1 2</td>
                    </tr>
                    <tr>
                        <td width="75" style="width:75px;">Cell 2 1</td>
                        <td width="400" style="width:400px;">Cell 2 2</td>
                    </tr>
                </table>
        </body>
</html>';
 
$docx->embedHTML($html);

$docx->createDocx('./result/10_transform_html_to_docx_multiple_table');

$docx = new TransformDocAdv();

$docx->transformDocument('./result/10_transform_html_to_docx_multiple_table.docx',
                './result/10_transform_html_to_docx_multiple_table.pdf',
                $tmp,
                array('odfconverter' => true, 'debug' => true));

I found the solution by removing one modification in your library on HTML2WordML:1343. 

self::$WordML = str_replace('#<w:gridCol/>#', str_repeat('<w:gridCol w:w="1"/>', $column), self::$WordML);


// to
self::$WordML = str_replace('#<w:gridCol/>#', str_repeat('<w:gridCol/>', $column), self::$WordML);

Please check the importance of this modification on your code...

Posted by admin  · 16-02-2016 - 11:46

Hello,

That attribute is required for the proper functioning of LibreOffice 4.3 and newest (and also some versions of OpenOffice). That's why we requested you to use LibreOffice instead of OpenOffice as conversion plugin.

If you're using OpenOffice, the default conversion plugin is LibreOffice since phpdocx 4.5, it's better to remove it. We're going to add a new option to avoid the use of that attribute when working with OpenOffice by default.

We have sent you an email with a minor change in the class to find an automatic general fix without adding a new option.

Regards.