Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems downloading doc Error in content #1372

Closed
1 of 3 tasks
eulemis opened this issue May 19, 2018 · 5 comments
Closed
1 of 3 tasks

Problems downloading doc Error in content #1372

eulemis opened this issue May 19, 2018 · 5 comments

Comments

@eulemis
Copy link

eulemis commented May 19, 2018

This is:

Expected Behavior

Document can be opened

Current Behavior

when downloading the file the word tells me that the content of the file is damaged if I give it that I accept the risks it opens me without problems how to correct this problem?

Failure Information

if I remove these lines does not give me the warning

How to Reproduce

<?php
require __DIR__ . '/vendor/autoload.php';

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$textrun = $section->addTextRun();
$textrun->addText($num.'.'.$texto1);
$textrun->addText(htmlspecialchars_decode($titulo), ['italic' => true]);
$textrun->addText(htmlspecialchars_decode($texto2);

Context

  • PHP version:
  • PHPWord version: 0.14
@troosan
Copy link
Contributor

troosan commented May 20, 2018

what is the text you are trying to add?

@eulemis
Copy link
Author

eulemis commented May 20, 2018

Thanks for answering what I show are some bibliographical references, that come in an array which I cross and I separate to be able to give the cursive style to the titles and then I show with addListItemRun a list of each reference.
this is the string array that I receive in a method

result:{,…}
0: "Hernandez, E. A. (2011). :Capitulo I- El Renacer de un mejor pais:. En Palacios, J.(Ed/s.). El Bachaqueo en venezuela (pp.500). Valles del Tuy: Edit. Rombo."
1:"Hernandez, E., Camaro, L., Lopez, N., Sanchez, J. F. y Sanchez, M.L.  (s.f). :El Renacimiento:. Valles del tuy: renacer."
2:"Sanoja, T. (1990). :Emprendimiento en tiempo de crisis:. Valles del tuy: Renacer."
3:"Dominguez, K. (2010). :El Despertar:. Program ade superacion: lunes."
4:"Hernandez, S.E.  (1988). :TodospodemosconDios:. Contruye: ."
5:"El libro sin autor.(2012). Valles del tuy: Renacer."

And this is the function that runs through that string array

foreach($refer as $r){
            $arrDivTitulo = explode(':', ($r));
            
            $texto1 = $arrDivTitulo[0];
            $titulo = $arrDivTitulo[1];
            $texto2 = $arrDivTitulo[2];

                        
            $listItemRun = $section->addListItemRun();
            $listItemRun->addText(htmlspecialchars($texto1), array('alignment' => \PhpOffice\PhpWord\SimpleType\Jc::DISTRIBUTE));
            $listItemRun->addText(htmlspecialchars($titulo), array('italic' => true));
            $listItemRun->addText(htmlspecialchars($texto2), null, array('keepNext' => true, 'indentation' => array('firstLine' => 340)));
        }

@troosan
Copy link
Contributor

troosan commented May 20, 2018

this works fine, except that your entry 5 does not contain a :

@eulemis
Copy link
Author

eulemis commented May 20, 2018

Excuse me but what is the entrance 5, I do not understand much the answer, maybe I'm dull with so many attempts could clarify me?

@eulemis
Copy link
Author

eulemis commented May 20, 2018

Excuse me again, I saw what he was referring to in Array 5, I corrected him and it worked, thank you very much. God bless you.

@troosan troosan closed this as completed May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants