Skip to content

Few Issues with PHPWord #1889

Open
Open
@jaydjohno

Description

@jaydjohno

PHP Word has been amazing for what i need to achieve, however there is a few issues that i have noticed a few other people have had but i can't seem to figure out how to fix.

I am using the templates processing, and anything to to do with blocks doesn't work, i am attempting a delete block, replace block and also a cloneblock. None of them sem to work.

Here is my code

if (in_array($country, $eu_countries)) 
{
$invoiceProcessor->replaceBlock('VAT', 'VAT: ' . get_post_meta($payment->ID ) );
}
 else
{
$invoiceProcessor->deleteBlock('VAT');
} 

Here is the template tag

${VAT}
This should be deleted replaced.
${/VAT}

Does nothing.

I then have a for loop that creates a cloneblock based on a count, i even removed this and tried to do it manually but still doesn't work.

$standardProcessor->cloneBlock('CLONEME', 3);

This is my block

${CLONEME}
${audio_file}
${/CLONEME}

and i replace the value inside with this:

$standardProcessor->setValue( 'audio_file' , $item['name'], 1 );

Again the value will be replaced with the count but thie audio file is replaced but the block isn't cloned, no matter which way i try to set it up. Is this an issue with the blocks processor.

The other issue i have is when converting my finished .docx to PDF the formatitng is all messed up, i am using DOMPDF, but this doesn't keep the same formatting if it is converted, whats the best way of converting the template to PDF without breaking the format.

thanks for your help

Jay

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions