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

Add ability to manage header & footer height #5

Closed
JillElaine opened this issue Aug 2, 2012 · 2 comments
Closed

Add ability to manage header & footer height #5

JillElaine opened this issue Aug 2, 2012 · 2 comments
Assignees
Milestone

Comments

@JillElaine
Copy link

The code to do this is here: https://phpword.codeplex.com/discussions/316726
Here is the related 'workitem' on the phpWord site: https://phpword.codeplex.com/workitem/35

@Progi1984
Copy link
Member

The feature has been added in the develop branch.

@jcnolan
Copy link

jcnolan commented Oct 8, 2016

Note, successfully tested in v0.13.0 to place 8.5" x 11" image as watermark on micro-perf stock template.

   $PidPageSettings = array(
            'headerHeight'=> \PhpOffice\PhpWord\Shared\Converter::inchToTwip(.2),
            'footerHeight'=> \PhpOffice\PhpWord\Shared\Converter::inchToTwip(.2),
            'marginLeft'  => \PhpOffice\PhpWord\Shared\Converter::inchToTwip(.75),
            'marginRight' => \PhpOffice\PhpWord\Shared\Converter::inchToTwip(.75),
            'marginTop'   => 0,
            'marginBottom'=> 0,
        );

        $section = $this->phpword->createSection($PidPageSettings);
        $header = $section->addHeader();

        $foo = array(
            'width'            => \PhpOffice\PhpWord\Shared\Converter::inchToPixel(8.5),
            'height'           => \PhpOffice\PhpWord\Shared\Converter::inchToPixel(11),
            'positioning'      => \PhpOffice\PhpWord\Style\Image::POSITION_ABSOLUTE,
            'posHorizontal'    => \PhpOffice\PhpWord\Style\Image::POSITION_HORIZONTAL_CENTER,
            'posHorizontalRel' => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
            'posVerticalRel'   => \PhpOffice\PhpWord\Style\Image::POSITION_RELATIVE_TO_PAGE,
        );

        if ($fName) $header->addWatermark($fName, $foo); // $fName would be your 8.5" x 11" image

Was using PHPWord to create documents to be printed on micro-perforated card stock and was placing a scan of the template as a watermark for debugging purposes and required a .2" header / footer. The following proceeding code worked but ALL values needed to be set to create a properly working document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants