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

Error with the centralization of the watermark. #1442

Open
1 of 3 tasks
winadv opened this issue Jul 26, 2018 · 1 comment
Open
1 of 3 tasks

Error with the centralization of the watermark. #1442

winadv opened this issue Jul 26, 2018 · 1 comment

Comments

@winadv
Copy link

winadv commented Jul 26, 2018

This is:

Expected Behavior

Center the watermark in the middle of the page both horizontally and vertically. My image has the following dimensions in pixels 1334x447.

Current Behavior

It just inserts the image below the others in the header. I have already tried marginTop and nothing.

Failure Information

I want my watermark to be centered in the middle of the page. I've tried every possible way and I could not, I believe it's a Word protection because the watermark is linked to the header.

Thank you very much in advance.

How to Reproduce

<?php
$phpWord = new \PhpOffice\PhpWord\PhpWord();

$paragraphStyleName = 'pStyle';
$phpWord->addParagraphStyle($paragraphStyleName, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'spaceAfter' => 0, 'contextualSpacing' => true));

$fontStyleEffra['name'] = 'Effra';
$fontStyleEffra['size'] = 8;

// Adding an empty Section to the document...
$section = $phpWord->addSection();
$header = $section->addHeader();
$header->addImage('./plugins/mpdf60/img/logo.png', array('width' => 45, 'positioning' => 'relative'));
$header->addImage('./plugins/mpdf60/img/border.jpg', array('width' => 535, 'positioning' => 'relative', 'marginTop' => -200));
$header->addWatermark('./plugins/mpdf60/img/backgroundword.png', array( 'positioning' => 'relative', 'marginTop' => 1000, 'width'  => 535, 'wrappingStyle' => 'behind'));



$footer = $section->addFooter();
$footer->addImage('./plugins/mpdf60/img/border.jpg', array('width' => 535));
$footer->addText('Text01', $fontStyleEffra, $paragraphStyleName);
$footer->addText('Text02', $fontStyleEffra, $paragraphStyleName);

// Adding Text element to the Section having font styled by default...
$templateProcessor->addText(
    '"Learn from yesterday, live for today, hope for tomorrow. '
        . 'The important thing is not to stop questioning." '
        . '(Albert Einstein)"'
);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('file.docx');
>...

Context

  • PHP version: 5.6
  • PHPWord version: 0.15
@andasen
Copy link

andasen commented Apr 27, 2019

This is:

Expected Behavior

Center the watermark in the middle of the page both horizontally and vertically. My image has the following dimensions in pixels 1334x447.

Current Behavior

It just inserts the image below the others in the header. I have already tried marginTop and nothing.

Failure Information

I want my watermark to be centered in the middle of the page. I've tried every possible way and I could not, I believe it's a Word protection because the watermark is linked to the header.

Thank you very much in advance.

How to Reproduce

<?php
$phpWord = new \PhpOffice\PhpWord\PhpWord();

$paragraphStyleName = 'pStyle';
$phpWord->addParagraphStyle($paragraphStyleName, array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER, 'spaceAfter' => 0, 'contextualSpacing' => true));

$fontStyleEffra['name'] = 'Effra';
$fontStyleEffra['size'] = 8;

// Adding an empty Section to the document...
$section = $phpWord->addSection();
$header = $section->addHeader();
$header->addImage('./plugins/mpdf60/img/logo.png', array('width' => 45, 'positioning' => 'relative'));
$header->addImage('./plugins/mpdf60/img/border.jpg', array('width' => 535, 'positioning' => 'relative', 'marginTop' => -200));
$header->addWatermark('./plugins/mpdf60/img/backgroundword.png', array( 'positioning' => 'relative', 'marginTop' => 1000, 'width'  => 535, 'wrappingStyle' => 'behind'));



$footer = $section->addFooter();
$footer->addImage('./plugins/mpdf60/img/border.jpg', array('width' => 535));
$footer->addText('Text01', $fontStyleEffra, $paragraphStyleName);
$footer->addText('Text02', $fontStyleEffra, $paragraphStyleName);

// Adding Text element to the Section having font styled by default...
$templateProcessor->addText(
    '"Learn from yesterday, live for today, hope for tomorrow. '
        . 'The important thing is not to stop questioning." '
        . '(Albert Einstein)"'
);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('file.docx');
>...

Context

  • PHP version: 5.6
  • PHPWord version: 0.15

did you solve this problem yet? i also met that, and cannot fix the watermark.

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

2 participants