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

Word Table bottom margin not rendering (solution provided) #422

Open
BKarrfalt opened this issue Nov 13, 2014 · 2 comments
Open

Word Table bottom margin not rendering (solution provided) #422

BKarrfalt opened this issue Nov 13, 2014 · 2 comments

Comments

@BKarrfalt
Copy link

BKarrfalt commented Nov 13, 2014

I encountered a bug where if you define a Table style in Word as:

$tableStyle = array(
       'cellMarginRight' => 100,
       'cellMarginTop' => 100,
       'cellMarginBottom' => 100,
       'cellMarginLeft' => 100,
); 

or

$tableStyle = array(
       'cellMargin' => 100,
);

The <w:bottom> element was not being rendered to the XML:

<w:tbl>
    <w:tblPr>
        <w:tblW w:w="5000" w:type="pct"/>
        <w:tblCellMar>
            <w:top w:w="100" w:type="dxa"/>
            <w:left w:w="100" w:type="dxa"/>
            <w:right w:w="100" w:type="dxa"/>
        </w:tblCellMar>
    </w:tblPr>
</w:tbl>

where it should render as

        <w:tblCellMar>
            <w:top w:w="100" w:type="dxa"/>
            <w:left w:w="100" w:type="dxa"/>
            <w:right w:w="100" w:type="dxa"/>
            <w:bottom w:w="100" w:type="dxa"/>  <!-- missing element -->
        </w:tblCellMar>

This is because in Writer/Word2007/Style/MarginBorder.php, the parsing of the $this->sizes array is being prematurely truncated in the write() method. Removing the decrement on line# 58 resolves the issue:

    /**
     * Write style
     */
    public function write()
    {
        $xmlWriter = $this->getXmlWriter();

        $sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV');
        //$sizeCount = count($this->sizes) - 1;
        $sizeCount = count($this->sizes);

        for ($i = 0; $i < $sizeCount; $i++) {
            if ($this->sizes[$i] !== null) {
                $color = null;
                if (isset($this->colors[$i])) {
                    $color = $this->colors[$i];
                }
                $this->writeSide($xmlWriter, $sides[$i], $this->sizes[$i], $color);
            }
        }
    }

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@BKarrfalt BKarrfalt changed the title Word Table bottom border not rendering (solution provided) Word Table bottom margin not rendering (solution provided) Nov 13, 2014
@shlangus
Copy link

shlangus commented Dec 4, 2014

This issue affect border and margin. Tnx for solution!

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@github-actions github-actions bot added the Stale label Nov 18, 2022
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants