GithubHelp home page GithubHelp logo

Comments (2)

Progi1984 avatar Progi1984 commented on May 4, 2024

The feature has been added in the develop branch.

from phpword.

jcnolan avatar jcnolan commented on May 4, 2024

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.

from phpword.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.