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

PhpWord evenPage() and oddPage() methods aren't working #751

Closed
Globax opened this issue Mar 2, 2016 · 4 comments
Closed

PhpWord evenPage() and oddPage() methods aren't working #751

Globax opened this issue Mar 2, 2016 · 4 comments

Comments

@Globax
Copy link

Globax commented Mar 2, 2016

Hy, i use your awesome library PhpWord, but i have one problem with addHeader().

if i use this

$section = $phpWord->addSection([
        'marginTop' => PHPWordConverter::cmToTwip(0.75),
        'marginBottom' => PHPWordConverter::cmToTwip(2),
        'marginLeft' => PHPWordConverter::cmToTwip(3),
        'marginRight' => PHPWordConverter::cmToTwip(2)
    ]
);

$header = $section->addHeader();
$header->addText(htmlspecialchars('Header', ENT_COMPAT, 'UTF-8'), null);

i have "Header" on each page, id i add firtsPage() method

$header = $section->addHeader();
$header->firstPage();
$header->addText(htmlspecialchars('Header', ENT_COMPAT, 'UTF-8'), null);

i have "Header" on first page, thats works good, but if i use evenPage() method

$header = $section->addHeader();
$header->evenPage();
$header->addText(htmlspecialchars('Header', ENT_COMPAT, 'UTF-8'),

i have nothing, why?

But i realy need oddPage() method, how i can get it works?

@artuomvproskunin
Copy link

Hy, its work, but need some magic:

$footer = $section->addFooter(Header::AUTO);
$footer->addPreserveText('{PAGE}', null, ['align' => 'right']);

$footerEven = $section->addFooter(Header::EVEN);
$footerEven->addPreserveText('{PAGE}');

After this open ready document and in "work with headers" set checkbox "different headers for odd and even pages"

@Globax
Copy link
Author

Globax commented Mar 13, 2016

Hmm, looks like
$section->addHeader(Header::FIRST);
set checkbox automatically for Different First Page, but
$section->addHeader(Header::EVEN);
not, seems like the bug

Anyway thank you very much :)

@jaff521
Copy link

jaff521 commented Dec 2, 2016

I used the codes given by artuomvproskunin to make different page footers, but failed, will you have a new solution??

@troosan
Copy link
Contributor

troosan commented Jun 27, 2017

The following PR #981 fixes this issue

@troosan troosan closed this as completed Jul 1, 2017
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

4 participants