How to delete a Macro using phpword?

36 Views Asked by At

I am using phpword to manipulate Word Documents. I am currently working with the templateProcessor class.

My template has some macros associated with variables which may receive blank strings. This is the code behind it:

for ($i = 1; $i <= 10; $i++) {
    ${"objetivo$i"} = $data["objetivo$i"];
}

$valoresObjetivos = [
    'objetivo1' => $objetivo1,
    'objetivo2' => $objetivo2,
    'objetivo3' => $objetivo3,
    'objetivo4' => $objetivo4,
    'objetivo5' => $objetivo5,
    'objetivo6' => $objetivo6,
    'objetivo7' => $objetivo7,
    'objetivo8' => $objetivo8,
    'objetivo9' => $objetivo9,
    'objetivo10' => $objetivo10,
];

// Add char • before variable value
$valoresObjetivos = array_map(function ($valor) {
    return ($valor !== '') ? "• $valor" : $valor;
}, $valoresObjetivos);

// Delete empty variables
$valoresObjetivos = array_map(function ($valor) {
    return ($valor === '') ? "" : $valor;
}, $valoresObjetivos);

$templateProcessor->setValues($valoresObjetivos);

The problem is i'm dealing with blank lines in my word document. The first image is the template and the second image is the final document. template final document. I'd like to remove those blank lines. Is there a way I can do it using phpWord?

Thank you very much!

Tried to remove blank linkes. Were expecting to be successfull. I wasn't successfull.

0

There are 0 best solutions below