Forum


Replies: 13   Views: 3221
Add section and change page orientation with htmlextended
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by gmakstutis  · 26-05-2019 - 10:15

I'm trying, as you suggested, to use 'fragments'. However, this is still proving difficult.

I've setup the Twig template to do this:

{# set the portrait variable to raw WordML #}
{% set portrait = '<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:pPr><w:sectPr><w:pgSz w:code="9" w:h="16838" w:orient="portrait" w:w="11906"/><w:pgMar w:bottom="850" w:footer="708" w:gutter="0" w:header="708" w:left="1077" w:right="1077" w:top="850"/><w:cols w:num="1" w:space="708"/><w:docGrid w:linePitch="360"/></w:sectPr></w:pPr></w:p>' %}

{# generate a variable with the result of phpdocx_wordML tag #}
{% set portfrag = "<phpdocx_wordML data-content='{{ portrait }}' />" %}

{# output #}
<phpdocx_wordfragment data-content="{{ portfrag|base64encode }}" />

This has required the creation of a custom Twig Filter (base64encode).

So far, this isn't working. 

The problem might be my custom twig filter, since I'm not very familiar with developing for twig; but it is a relatively simple filter so I don't think it is the problem.

However, this has raised another question. If the <phpdocx_wordfragment /> always requires the calling of the PHP functions base64_encode and serialize, couldn't this be included in the phpdocx function that parses the <phpdocx_wordfragment /> tag?

Many thanks for your assistance.