Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Note that this document was generated using the demo script 'readme.php' which c
3<0.12.44>

- replaced each() method for PHP 7.2 compatibility reason #96
- applied PR #98

3<0.12.43>

Expand Down Expand Up @@ -367,6 +368,8 @@ The other options are described here below
'outerLineThickness' => <number>, the thickness of the outer lines, defaults to 1
'protectRows' => <number>, the number of rows to keep with the heading, if there are less than this on a page, then all is moved to the next page.
'nextPageY'=> true or false (eg. 0 or 1) Sets the same Y position of the table for all future pages
'evenColumns' => 0, 1, 3, Set set all columns to the same widths, version 0.12.44
'evenColumnsMin' => <number>, the minimum width a column should have

<b>0.12.9:</b>
'shadeHeadingCol'=>(r,g,b) array, defining the backgound color of headings, default is empty
Expand Down
3 changes: 2 additions & 1 deletion examples/table-enhancements.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
$cols = array('num' => 'No', 'type' => 'Type', 'name' => '<i>Alias</i>');

$conf = array(
'evenColumns' => 1,
'evenColumns' => 2,
'evenColumnsMin' => 40,
'maxWidth' => 350,
'shadeHeadingCol' => array(0.6, 0.6, 0.5),
'shaded' => 1,
Expand Down
Binary file modified readme.pdf
Binary file not shown.
23 changes: 22 additions & 1 deletion src/Cezpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ public function ezTable(&$data, $cols = '', $title = '', $options = '')
'width' => 0, 'maxWidth' => 0, 'titleGap' => 5, 'gap' => 5, 'xPos' => 'centre', 'xOrientation' => 'centre',
'minRowSpace' => -100, 'rowGap' => 2, 'colGap' => 5, 'splitRows' => 0, 'protectRows' => 1, 'nextPageY' => 0,
/* other */
'showHeadings' => 1, 'cols' => array(), 'evenColumns' => 0,
'showHeadings' => 1, 'cols' => array(), 'evenColumns' => 0, 'evenColumnsMin' => 20
);

foreach ($defaults as $key => $value) {
Expand Down Expand Up @@ -1335,6 +1335,27 @@ public function ezTable(&$data, $cols = '', $title = '', $options = '')
$pos['_end_'] = $t;
}

// if the option is set to 2 and one of the columns is too narrow we need to look at recalculating the columns
if ($options['evenColumns'] == 2) {
$posVals = array();
foreach ($pos as $w) {
array_unshift($posVals, $w);
}
$narrowestCol = 9999;
$last = array_pop($posVals);
while (sizeof($posVals)) {
$current = array_pop($posVals);
$currentWidth = $current - $last;
if ($narrowestCol > $currentWidth) {
$narrowestCol = $currentWidth;
}
$last = $current;
}
if ($narrowestCol < $options['evenColumnsMin']) {
$options['evenColumns'] = 1;
}
}

// if the option is turned on we need to look at recalculating the columns
if ($options['evenColumns'] == 1) {
// what is the maximum width? it is either specified or the page width between the margins
Expand Down
2 changes: 1 addition & 1 deletion src/Cpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ private function o_fontDescendentCID($id, $action, $options = '')
$v = current($cid_widths);
$k = key($cid_widths);

while($v) {
while ($v) {
$nextv = next($cid_widths);
$nextk = key($cid_widths);

Expand Down