Hi,

I've extract and compile code lines for you.
If you have able to participate to the next Summit, you will get special
gift containing some example of phpword code.
It works with the v0.12.1

here the code, and let me know.


C_BLOB($Blob)

$NomSortie:="DocumentName.docx"


$PhpCode:=Create document($script)
$script_t:=""
$script_t:=$script_t+"<?php\r"

$script_t:=$script_t+"// PHP Word\r"
$script_t:=$script_t+"require_once __DIR__ .
'/PhpOffice/PhpWord/Autoloader.php';\r"
$script_t:=$script_t+"use \\PhpOffice\\PhpWord\\Autoloader;\r"
$script_t:=$script_t+"use \\PhpOffice\\PhpWord\\Settings;\r"
$script_t:=$script_t+"use \\PhpOffice\\PhpWord\\IOFactory;\r"

$script_t:=$script_t+"Autoloader::register();\r"
$script_t:=$script_t+"Settings::loadConfig();\r\r"

$script_t:=$script_t+"  // create new PHPWord object\r"
$script_t:=$script_t+"$PHPWord=new \\PhpOffice\\PhpWord\\PhpWord();\r\r"

$script_t:=$script_t+"  // new section\r"
$script_t:=$script_t+"$section=$PHPWord->createSection();\r"  // portrait by
default
$script_t:=$script_t+"$section->getSettings()->setPageNumberingStart(1);\r"
$script_t:=$script_t+"$section->addText(htmlspecialchars('"+Export_Echappement
($Texte)+"'));\r"
$script_t:=$script_t+"$objWriter=\\PhpOffice\\PhpWord\\IOFactory::createWriter($PHPWord,
'Word2007');\r"
$script_t:=$script_t+"$objWriter->save('"+$NomSortie+"');\r ?>"


CONVERT FROM TEXT($script_t;"UTF-8";$Blob)
$Texte:=Convert to text($Blob;"UTF-8")
SEND PACKET($PhpCode;$Texte)
CLOSE DOCUMENT($PhpCode)

        SET DATABASE PARAMETER(PHP use external interpreter;0)
        $OK:=PHP Execute("";"quit_4d_php")
        PHP SET OPTION(PHP raw result;True)
        $OK:=PHP Execute("";"relaunch_4d_php")
        DELAY PROCESS(Current process;20)
        
        ON ERR CALL("PHP_Error")
        While (($isOK=False) & ($compteur<3))  // Try 3 times before exit
                $Progression:=$Progression+$pas
                $compteur:=$compteur+1
                $isOK:=PHP Execute($script;"";$result)
                DELAY PROCESS(Current process;15)  // 1/4 seconde delay
        End while
        
        $isOK:=PHP Execute("";"quit_4d_php")





-----
Patrick EMANUEL
------------------------------------------------------------
Administrator
www.association-qualisoft.eu 
(Soft1002, Simply Asso & QS_Toolbox)
--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to