jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/372139 )

Change subject: UEModulePDF: Fix for tables being too wide
......................................................................


UEModulePDF: Fix for tables being too wide

In tables with many columns it can happen that the table overflows the
width of the size in PDF export.

Since table-layout must be set, it cannot be done by simple setting
"width" attribute of table, but in this, a little hacky way, to alter
"style" tag.

It can also be done over css class, which would more elegantly be added to
tables in php, but this might not work, in case wiki uses custom skin,
which does not have class defined.

Change-Id: I85f3078a68c22b4b8a187842a3548132d58b9a6f
ERM: #3591
---
M UEModulePDF/includes/PDFPageProvider.class.php
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/UEModulePDF/includes/PDFPageProvider.class.php 
b/UEModulePDF/includes/PDFPageProvider.class.php
index 36bf034..d65e4d1 100644
--- a/UEModulePDF/includes/PDFPageProvider.class.php
+++ b/UEModulePDF/includes/PDFPageProvider.class.php
@@ -276,6 +276,8 @@
                //Make tables paginatable
                $oTableElements = $oPageDOM->getElementsByTagName( 'table' );
                foreach( $oTableElements as $oTableElement ) {
+                       self::correctTableWidth( $oTableElement );
+
                        $oTableRows = $oTableElement->childNodes; //We only 
want direct children, so we cannot use getElementsByTagName
                        $aRows = array();
                        foreach( $oTableRows as $oTableRow ){
@@ -320,4 +322,13 @@
                $oAntiBugP->setAttribute( 'style', 
'visibility:hidden;height:0px;margin:0px;padding:0px' );
                $oBodyContent->insertBefore( $oAntiBugP, 
$oBodyContent->firstChild );
        }
+
+       protected static function correctTableWidth( $oTableElement ) {
+               $sStyleAttribute = $oTableElement->getAttribute( 'style' );
+               //make sure style tag ends with semicolon
+               if( substr( trim( $sStyleAttribute ), -1 ) !== ";" ) {
+                       $sStyleAttribute .= ";";
+               }
+               $oTableElement->setAttribute( 'style', $sStyleAttribute . ' 
table-layout: fixed; max-width: 700px;' );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/372139
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I85f3078a68c22b4b8a187842a3548132d58b9a6f
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: ItSpiderman <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to