public function replace($variables = NULL, $document = NUll) { require_once '../Vendor/phpdocxCorporate/classes/TransformDoc.inc'; require_once '../Vendor/phpdocxCorporate/classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('system/documents/' . $document); // templete $first_nem$ $options = array('parseLineBreaks' => true); $docx->replaceVariableByText($variables, $options); $name = md5(microtime()); $docx->createDocx($name); return $name; }
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/MultipleSections.docx'); //using the sectionNumers option one may choose the sections that one wishes to modify $docx->modifyPageLayout('A4-landscape', array('numberCols' => '2', 'sectionNumbers' => array(2))); $docx->createDocx('example_modifyPageLayout_2');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateWordML.docx'); //beware that this method does not take care of relationships and dependences //so you have to make sure that the wordML is 'self-contained' //we recommend to avoid this method unless one really knows the underlying OOXML standard $wordML = '<w:p> <w:r> <w:t xml:space="preserve">This is a simple paragraph with some </w:t> </w:r> <w:r> <w:rPr> <w:b/> </w:rPr> <w:t>bold</w:t> </w:r> <w:r > <w:t xml:space="preserve"> text.</w:t> </w:r> </w:p>'; $docx->replaceVariableByWordML(array('WORDML' => $wordML)); $docx->createDocx('example_replaceVariableByWordML_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateSimpleTable.docx'); $data = array(array('ITEM' => 'Product A', 'REFERENCE' => '107AW3'), array('ITEM' => 'Product B', 'REFERENCE' => '204RS67O'), array('ITEM' => 'Product C', 'REFERENCE' => '25GTR56')); $docx->replaceTableVariable($data, array('parseLineBreaks' => true)); $docx->createDocx('example_replaceTableVariable_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/Checkbox.docx'); $variables = array('check1' => 1, 'check2' => 0, 'check3' => 1); $docx->tickCheckboxes($variables); $docx->createDocx('example_tickCheckboxes_1');
function cron_tpl_merge_process($tpls, $entry, $type = "", $invoice_number = "") { echo "inside merge process.<br/>"; require_once "D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\classes\\TransformDocAdv.inc"; require_once "D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\classes\\CreateDocx.inc"; $final_doc_url = ""; $formdetail = RGFormsModel::get_form($entry["form_id"]); $new_xml = array(); $unique_number = date('ymdhis') . "-" . $entry["id"]; $n = str_replace('+', '_', urlencode($formdetail->title)) . ($type != "" ? "_" . $type : "") . "_" . $unique_number . '-cron.docx'; if ($type == "Invoice" && $invoice_number == "") { $invoice_number = generate_invoice_number(); } $i = 1; foreach ($tpls as $tpl) { $file = $tpl['file']; $value = $tpl['values']; $value["Invoice_number"] = $invoice_number; if (!empty($file['dir_path']) && !empty($file['filepath'])) { $cookie_file_path = $file['filepath']; /*echo '<br/>Cookie path: '.$cookie_file_path; if (!file_exists($cookie_file_path)) { echo 'file does not exist'; } else { echo 'file exists'; }*/ //Create PHPDocx object using the template file defined above. $docx = new CreateDocxFromTemplate($cookie_file_path); $variables = array(); $variables_html = array(); foreach ($value as $k => $v) { $k_val = explode("-", $k); $e_val = array("SIGNED", "PRESENCE", "LengthContent"); if (count($k_val) > 1 && in_array($k_val[1], $e_val)) { $variables_html[$k] = $v; } else { $variables[$k] = $v; } } //Load the array into the PHPDocx object so that the variable values are inserted into the document template. $docx->replaceVariableByText($variables); if (!empty($variables_html)) { foreach ($variables_html as $hk => $hv) { if (!empty($hv)) { $docx->replaceVariableByHTML($hk, 'inline', $hv, array()); } else { $docx->replaceVariableByText(array($hk => "")); } } } //echo '<br/>About to check if file exists...'; if (!file_exists($file['dir_path'] . '/doc/temps/cron/')) { mkdir($file['dir_path'] . '/doc/temps/cron/', 0777, true); } //Define the output location and name of the document to be saved (e.g. Saves in 'Output' folder relative to the location //Of this script, and the name of the file will be 'testDeed'. $outputWordFileNameAndPath = $file['dir_path'] . '/doc/temps/cron/' . date('ymdhis') . $i . '-cron'; $newfile = $outputWordFileNameAndPath . ".docx"; $newfile_pdf = $outputWordFileNameAndPath . ".pdf"; //Define the base directory $baseDirectory = ''; //Create the document and save it. $docx->createDocx($outputWordFileNameAndPath); //Conver the document to PDF and save. $docx->transformDocxUsingMSWord($baseDirectory . $outputWordFileNameAndPath . '.docx', $baseDirectory . $outputWordFileNameAndPath . '.pdf'); if (file_exists($newfile_pdf)) { //chmod($newfile_pdf, 0777); $new_xml['temp_file'][] = $newfile_pdf; //chmod($newfile_pdf, 0777); } } $i++; } $c = count($new_xml['temp_file']); if (!file_exists($file['dir_path'] . '/doc/cron/')) { mkdir($file['dir_path'] . '/doc/cron/', 0777, true); } $final_doc = $file['dir_path'] . '/doc/cron/' . $n; $final_doc = str_replace('.docx', '.pdf', $final_doc); $final_doc = str_replace("/", "\\", $final_doc); $final_doc = str_replace("\\", "\\\\", $final_doc); $final_doc_url = $file['dir_url'] . '/doc/cron/' . $n; $final_doc_url = str_replace('.docx', '.pdf', $final_doc_url); if ($c > 1) { $alldoc = $new_xml['temp_file']; cron_mergerAllPdf($alldoc, $final_doc); } else { copy($new_xml['temp_file'][0], $final_doc); } if (file_exists($final_doc)) { chmod($final_doc, 0777); foreach ($new_xml['temp_file'] as $y) { if (file_exists(ConvertDirectoryPath($y))) { chmod(ConvertDirectoryPath($y), 0777); } @unlink(ConvertDirectoryPath($y)); $y = str_replace(".pdf", ".docx", $y); @unlink(ConvertDirectoryPath($y)); } cron_SaveToDB($final_doc_url, $final_doc, $entry["id"], $type, $invoice_number); return $final_doc_url; } foreach ($new_xml['temp_file'] as $y) { if (file_exists(ConvertDirectoryPath($y))) { chmod(ConvertDirectoryPath($y), 0777); } @unlink(ConvertDirectoryPath($y)); $y = str_replace(".pdf", ".docx", $y); @unlink(ConvertDirectoryPath($y)); } return ""; }
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/placeholderImageFootnote.docx'); $image_1 = array('height' => 2, 'width' => 2, 'target' => 'footnote'); $docx->replacePlaceholderImage('FOOTNOTEIMG', '../../img/logo_header.jpg', $image_1); $docx->createDocx('example_replacePlaceholderImages_2');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateComplexTable.docx'); $docx->setTemplateSymbol('@'); $data = array(array('ITEM' => 'Product A', 'REFERENCE' => '107AW3', 'PRICE' => '5.45'), array('ITEM' => 'Product B', 'REFERENCE' => '204RS67O', 'PRICE' => '30.12'), array('ITEM' => 'Product C', 'REFERENCE' => '25GTR56', 'PRICE' => '7.00')); $docx->replaceTableVariable($data); $docx->createDocx('example_replaceTableVariable_2');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateHTML.docx'); $docx->replaceVariableByHTML('ADDRESS', 'inline', '<p style="font-family: verdana; font-size: 11px">C/ MatÃas Turrión 24, Madrid 28043 <b>Spain</b></p>', array('isFile' => false, 'parseDivsAsPs' => true, 'downloadImages' => false)); $docx->replaceVariableByHTML('CHUNK_1', 'block', 'http://www.2mdc.com/PHPDOCX/example.html', array('isFile' => true, 'parseDivsAsPs' => true, 'filter' => '#capa_bg_bottom', 'downloadImages' => true)); $docx->replaceVariableByHTML('CHUNK_2', 'block', 'http://www.2mdc.com/PHPDOCX/example.html', array('isFile' => true, 'parseDivsAsPs' => false, 'filter' => '#lateral', 'downloadImages' => true)); $docx->createDocx('example_replaceTemplateVariableByHTML_1');
function tpl_merge_process($tpls, $entry, $type = "") { /* require_once 'PHPWord.php'; require_once 'phpdocx/classes/MultiMerge.inc'; //require_once 'phpdocx/classes/CreateDocx.inc'; */ require_once "phpdocx-v4/classes/TransformDocAdv.inc"; require_once "phpdocx-v4/classes/CreateDocx.inc"; $final_doc_url = ""; $formdetail = RGFormsModel::get_form($entry["form_id"]); $unique_number = date('ymdhis'); $n = str_replace('+', '_', urlencode($formdetail->title)) . ($type != "" ? "_" . $type : "") . "_" . $unique_number . '.docx'; $invoice_number = ""; if ($type == "Invoice") { $invoice_number = generate_invoice_number(); } $i = 1; foreach ($tpls as $tpl) { $file = $tpl['file']; $value = $tpl['values']; $value["Invoice_number"] = $invoice_number; if (!empty($file['dir_path']) && !empty($file['filepath'])) { $cookie_file_path = $file['filepath']; //Create PHPDocx object using the template file defined above. $docx = new CreateDocxFromTemplate($cookie_file_path); $variables = array(); $variables_html = array(); foreach ($value as $k => $v) { $k_val = explode("-", $k); $e_val = array("SIGNED", "PRESENCE", "LengthContent"); if (count($k_val) > 1 && in_array($k_val[1], $e_val)) { $variables_html[$k] = $v; } else { $variables[$k] = $v; } } // printp($variables_html);exit; //Load the array into the PHPDocx object so that the variable values are inserted into the document template. $docx->replaceVariableByText($variables); if (!empty($variables_html)) { foreach ($variables_html as $hk => $hv) { if (!empty($hv)) { $docx->replaceVariableByHTML($hk, 'inline', $hv, array()); } else { $docx->replaceVariableByText(array($hk => "")); } } } /*$new_xml['xml'][] = $document->getTemplateXML(); $new_xml['file'][] = $document->getTempFileName(); if(file_exists($document->getTempFileName())){ chmod($document->getTempFileName(), 0777); }*/ if (!file_exists($file['dir_path'] . '/doc/temps/cron/')) { mkdir($file['dir_path'] . '/doc/temps/cron/', 0777, true); } //Define the output location and name of the document to be saved (e.g. Saves in 'Output' folder relative to the location //Of this script, and the name of the file will be 'testDeed'. $outputWordFileNameAndPath = $file['dir_path'] . '/doc/temps/cron/' . date('ymdhis') . $i . '-cron'; $newfile = $outputWordFileNameAndPath . ".docx"; $newfile_pdf = $outputWordFileNameAndPath . ".pdf"; //Define the base directory $baseDirectory = ''; //Create the document and save it. $docx->createDocx($outputWordFileNameAndPath); //Conver the document to PDF and save. $docx->transformDocxUsingMSWord($baseDirectory . $outputWordFileNameAndPath . '.docx', $baseDirectory . $outputWordFileNameAndPath . '.pdf'); if (file_exists($newfile_pdf)) { chmod($newfile_pdf, 0777); $new_xml['temp_file'][] = $newfile_pdf; chmod($newfile_pdf, 0777); } } $i++; /*$document->save($newfile); if(file_exists($newfile)){ chmod($newfile, 0777); $newfile = converttoPDF(str_replace("/","\\",$newfile)); $new_xml['temp_file'][] = $newfile; chmod($newfile, 0777); }*/ } $c = count($new_xml['temp_file']); $final_doc = $file['dir_path'] . '/doc/' . $n; $final_doc = str_replace('.docx', '.pdf', $final_doc); $final_doc = str_replace("/", "\\", $final_doc); $final_doc = str_replace("\\", "\\\\", $final_doc); $final_doc_url = $file['dir_url'] . '/doc/' . $n; $final_doc_url = str_replace('.docx', '.pdf', $final_doc_url); if ($c > 1) { $alldoc = $new_xml['temp_file']; mergerAllPdf($alldoc, $final_doc); } else { copy($new_xml['temp_file'][0], $final_doc); } if (file_exists($final_doc)) { chmod($final_doc, 0777); if ($type == "") { SaveDocToDb($entry, $final_doc_url, $final_doc, $unique_number); } else { //printp($invoice_number); UpdateDocToDb($entry, $final_doc_url, $final_doc, $type, $invoice_number); } foreach ($new_xml['temp_file'] as $y) { if (file_exists(ConvertDirectoryPath($y))) { chmod(ConvertDirectoryPath($y), 0777); } @unlink(ConvertDirectoryPath($y)); $y = str_replace(".pdf", ".docx", $y); @unlink(ConvertDirectoryPath($y)); } return $final_doc_url; } foreach ($new_xml['temp_file'] as $y) { if (file_exists(ConvertDirectoryPath($y))) { chmod(ConvertDirectoryPath($y), 0777); } @unlink(ConvertDirectoryPath($y)); $y = str_replace(".pdf", ".docx", $y); @unlink(ConvertDirectoryPath($y)); } return ""; // exit; }
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateVariables.docx'); //You may include manually the list of variables that should be preprocessed or use //the getTemplateVariables method for an automatic listing $variables = $docx->getTemplateVariables(); $docx->processTemplate($variables); $docx->createDocx('example_processTemplate_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/placeholderImage.docx'); $image_1 = array('height' => 3, 'width' => 3, 'target' => 'header'); $docx->replacePlaceholderImage('HEADERIMG', '../../img/logo_header.jpg', $image_1); $docx->replacePlaceholderImage('LOGO', '../../img/imageP3.png'); $docx->createDocx('example_replacePlaceholderImages_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/simpleTemplate.docx'); //parse styles of the current template //notice that besides the original template styles PHPDocX has included additional useful styles $docx->parseStyles(); $docx->createDocx('example_parseStyles_2');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateList.docx'); $items = array('First item', 'Second item', 'Third item'); $docx->replaceListVariable('LISTVAR', $items); $docx->createDocx('example_replaceListVariable_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/inputFields.docx'); $data = array('textfield_1' => 'first', 'textfield_2' => 'second', 'sdt_1' => 'third', 'sdt_2' => 'fourth'); $docx->modifyInputFields($data); $docx->createDocx('example_modifyInputFields_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateBlocks.docx'); $docx->clearBlocks(); $docx->createDocx('example_clearBlocks_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateBlocks.docx'); $docx->deleteTemplateBlock('FIRST'); $docx->createDocx('example_deleteTemplateBlock_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateVariables.docx'); print_r($docx->getTemplateVariables());
<?php error_reporting(E_ALL); ini_set("display_errors", 1); echo "STARTING INTO MERGE PROCESS<BR>"; require_once 'classes/TransformDocAdv.inc'; require_once 'classes/CreateDocx.inc'; echo "includes lib files<br>"; //Define the template file you wish to load. There is no need to load the Base Template anymore. $template = $_SERVER['DOCUMENT_ROOT'] . '\\doctopdf\\SSP-Ind-Trustees-2-to-4-Establish-02-02-15_4_trustees-.docx'; echo $template = $_SERVER['DOCUMENT_ROOT'] . '\\wp-content\\uploads\\templatemerge\\masters\\Deed-cover.docx'; echo "<br>template sample file<br>"; //Create PHPDocx object using the template file defined above. echo "Before Creating PHPDOCx object<br>"; $docx = new CreateDocxFromTemplate($template); echo "After Creating PHPDOCx object<br>"; //Define the variable names and values in an array. $variables = array('Name_of_Fund' => "This is a New FUND", 'T1_Name' => "MY T1", 'T2_name' => "MY T2", 'T3_name' => "MY T3", 'T4_name' => "MY T4", 'M1_Residential_Address_not_PO_Box' => "M1 Address", 'M2_Residential_Address_not_PO_Box' => "M2 Address", 'M3_Residential_Address_not_PO_Box' => "M3 Address", 'M4_Residential_Address_not_PO_Box' => "M4 Address", 'STREET_ADDRESS_WHERE_TRUSTEE_MEETINGS_AR' => "Street address meeting held at ", 'M1_Date_of_Birth_ddmmyy' => "01/12/1989", 'M2_Date_of_Birth_ddmmyy' => "02/12/1989", 'M3_Date_of_Birth_ddmmyy' => "03/12/1989", 'M4_Date_of_Birth_ddmmyy' => "04/12/1989", 'M1_Tax_File_Number' => "111111111", 'M2_Tax_File_Number' => "222222222", 'M3_Tax_File_Number' => "333333333", 'M4_Tax_File_Number' => "444444444"); //$variables = array('FUNDNAME' => 'The Test Family Super Fund', 'COMPANYNAME' => 'ABC PTY LTD', 'ACN' => '111 222 333', 'Address_Of_Registered_Office' => '123 Happy Street, Happyville, Victoria, 3000'); //Load the array into the PHPDocx object so that the variable values are inserted into the document template. $docx->replaceVariableByText($variables); //Define the output location and name of the document to be saved (e.g. Saves in 'Output' folder relative to the location //Of this script, and the name of the file will be 'testDeed'. $outputWordFileNameAndPath = 'output\\Deed-cover-ins'; //Define the base directory $baseDirectory = 'D:\\inetpub\\app\\wwwroot\\wp-content\\plugins\\templatemerge\\phpdocx-v4\\'; //Create the document and save it. $docx->createDocx($outputWordFileNameAndPath); //Conver the document to PDF and save. $docx->transformDocxUsingMSWord($baseDirectory . $outputWordFileNameAndPath . '.docx', $baseDirectory . $outputWordFileNameAndPath . '.pdf'); exit;
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplatePipeSymbol.docx'); $docx->setTemplateSymbol('|'); $docx->replaceVariableByText(array('FIRST' => 'Hello World!')); $docx->createDocx('example_setTemplateSymbol_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateExternalFile.docx'); $docx->replaceVariableByExternalFile(array('EXTERNAL' => '../../files/External.docx'), array('matchSource' => true)); $docx->createDocx('example_replaceVariableByExternalFile_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateSimpleText.docx'); $first = 'PHPDocX'; $multiline = 'This is the first line.\\nThis is the second line of text.'; $variables = array('FIRSTTEXT' => $first, 'MULTILINETEXT' => $multiline); $options = array('parseLineBreaks' => true); $docx->replaceVariableByText($variables, $options); $docx->createDocx('example_replaceVariableByText_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateVariables.docx'); //first we remove the whole pragraph the contains the 'FOOTERVAR' variable $docx->removeTemplateVariable('FOOTERVAR', 'block', 'footer'); //now we only remove the 'OTHERVAR' variable value $docx->removeTemplateVariable('OTHERVAR', 'inline'); //and to finish remove the line containing the FOOTNOTEVAR variable in the footnote $docx->removeTemplateVariable('FOOTNOTEVAR', 'block', 'footnote'); $docx->createDocx('example_removeTemplateVariable_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateWordFragment_1.docx'); //create the Word fragment that is going to replace the variable $wf = new WordFragment($docx, 'document'); //create an image fragment $image = new WordFragment($docx, 'document'); $image->addImage(array('src' => '../../img/image.png', 'scaling' => 50, 'float' => 'right', 'textWrap' => 1)); //and also a link fragment $link = new WordFragment($docx, 'document'); $link->addLink('link to Google', array('url' => 'http://www.google.es', 'color' => '0000FF', 'u' => 'single')); //and a footnote fragment $footnote = new WordFragment($docx, 'document'); $footnote->addFootnote(array('textDocument' => 'here it is', 'textFootnote' => 'This is the footnote text.')); //combine them to create a paragraph $text = array(); $text[] = $image; $text[] = array('text' => 'I am going to write a link: ', 'b' => 'on'); $text[] = $link; $text[] = array('text' => ' to illustrate how to include links. '); $text[] = array('text' => ' As you may see is extremely simple to do so and can be done with any other Word element. For example to include a footnote is also as simple as this: '); $text[] = $footnote; $text[] = array('text' => ' , as you see there is a footnote at the bootom of the page. ', 'color' => 'B70000'); //insert all the content in the Word fragment we are going to use for replacement $wf->addText($text); $docx->replaceVariableByWordFragment(array('WORDFRAGMENT' => $wf), array('type' => 'block')); $docx->createDocx('example_replaceVariable ByWordFragment_1');
<?php //path to the CreateDocx class within your PHPDocX installation require_once '../../../classes/CreateDocx.inc'; $docx = new CreateDocxFromTemplate('../../files/TemplateWordFragment_2.docx'); //create the Word fragment that is going to replace the variable //like the variable to replace is in a footnote we should it as target $wf = new WordFragment($docx, 'footnote'); //create an image fragment $image = new WordFragment($docx, 'footnote'); //Warning: you can not poition absolutely images in footnotes. That is a limitation of the Word interface not the standard. $image->addImage(array('src' => '../../img/image.png', 'scaling' => 10)); //and also a link fragment $link = new WordFragment($docx, 'footnote'); $link->addLink('link to Google', array('url' => 'http://www.google.es', 'color' => '0000FF', 'u' => 'single')); //combine them to create a paragraph $text = array(); $text[] = $image; $text[] = array('text' => 'I am going to write a link: ', 'b' => 'on'); $text[] = $link; $text[] = array('text' => ' to illustrate how to include links in a footnote. '); $text[] = array('text' => ' As you may see it is extremely simple to do so and can be done with any other Word element.'); //insert all the content in the Word fragment we are going to use for replacement $wf->addText($text); //we want to preserve the reference mark so we do an inline substitution to presereve the paragraph structure. //we also target the footnote that is where the placeholder variable is located $docx->replaceVariableByWordFragment(array('INLINEFRAGMENT' => $wf), array('type' => 'inline', 'target' => 'footnote')); $docx->createDocx('example_replaceVariable ByWordFragment_2');