PHPWord template creation - Replace text on title page .docx

Ok, so I am using PHPWord to create a template. Then, using the setValue function to replace various lines in the document, it all works correctly, but I have a title page in my document and no text is replaced on that page?

Is there any way to add this functionality. Basically all that needs to happen is the replacement (setValue) to be done in the xml corresponding to the title page (title and assets) (custom xml folder?). you can see them by extracting the .docx file after changing the file extension to .zip

https://github.com/PHPOffice/PHPWord/blob/master/src/PhpWord/Template.php

How I am currently creating .docx from templated.docx file:

<?php
include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s') , " Create new PhpWord object" , EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();

$document = $phpWord->loadTemplate('resources/Template_Proposal.docx');

$document->setValue('CONTACTNAME', 'John');
$document->setValue('BUSINESSNAME', 'JBS Marketing');
$document->setValue('WEBSITE', 'www.website.com.au');
$document->setValue('DATE', '07/07/2014');

$name = 'test-proposal.docx';
echo date('H:i:s'), " Write to Word2007 format", EOL;
$document->saveAs($name);
rename($name, "results/{$name}");

echo getEndingNotes(array('Word2007' => 'docx'));
if (!CLI) {
    include_once 'Sample_Footer.php';
}

      

+3
xml php templates docx phpword


source to share


No one has answered this question yet

Check out similar questions:

418
Explanation <script type = "text / template"> ... </script>
8
Finding and replacing text with PHPWord
8
PhpWord does not replace text
3
Why Office OpenXML splits text between tags and how to prevent it?
2
XML parsing error; PHPWord
1
Loading.docx with PHPWord
1
Load section from Template docx file in PHPword
0
PHPWORD - insert image in front of text on every page of docx file
0
embed PHPword docx file in PHPword docx file
0
PHPWord not working on IIS server



All Articles
Loading...
X
Show
Funny
Dev
Pics