I have bit of a conundrum. We're using PHPDocX to generate word files from some form data.
In order to do this we sometimes build a grid using tables. This works well on one level. So we might have a structuredTag for tex inpout, and then som text that runs atfer it. In that case we make a table and put the structured tag in one column and the text after.
But sometimes we need to have two columns. For that we also use a table and then put our content in each column.
The problem arrises when putting a table as content. I added a screenshot to show how it comes out. The third text and structuredTag needs to align to the left with the first two. The Label is put there just using addText()
https://pasteboard.co/HKZlx9ffQn4e.png
The outer table is setup like this:
$col1 = [ 'value' => $leftFragment, ]; $col2 = [ 'value' => $rightFragment, ]; // Create a table with two columns $table = [ [ $col1, $col2 ] ]; $tableOptions = [ 'tableLayout' => 'fixed', 'tableStyle' => 'PlainTablePHPDOCX' ];
And in the $leftFragment I have this table:
$options = [ 'placeholderText' => 'structuredTag, 'border' => 'single', 'borderSpacing' => 0, 'borderTopSpacing' => 0, 'borderBottomSpacing' => 0, 'spacingBottom' => 0, 'spacingTop' => 0, ]; $leftFragment->addStructuredDocumentTag('richText', $options); $rightFragment = new WordFragment($docx); $rightFragment->addText($'More text, [ 'spacingBottom' => 0, 'spacingTop' => 0, ]); $table = [ [ $leftFragment, $rightFragment ] ]; $tableOptions = [ 'tableLayout' => 'fixed', 'tableStyle' => 'PlainTablePHPDOCX', ]; $docx->addTable($table, $tableOptions);