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

Template processor - problems with production enviroment and word (office) #1735

Closed
Gadeoli opened this issue Oct 11, 2019 · 1 comment
Closed

Comments

@Gadeoli
Copy link

Gadeoli commented Oct 11, 2019

Describe the Bug

I used a lot of cloneBlone and CloneRow, SetValue and Images to generate files with 50 pages (more or less); Some generated files dont open on office (word), the files was broken. The templates are a bit large, so i didnt find the cause yet.

On wamp (Developer enviroment):

  • I can use setComplexValue for custom colors on my templates;
  • The generated .docx have colors && open on office (word) and libreoffice (writter).

On production (Ubuntu server)

  • The generated .docx dont keep the colors setted on setComplexValue (all is black) && some files generated dont open on office (word), but opens on libreoffice (writter);

Ps.: I already download the generated files by ftp, but the problem still happing on word.
I removed SetComplexValue use dont fix the word problem.
I convert to pdf with libreoffice --headless, but is not relevant to the problem

Steps to Reproduce

//Cant post my reports' full code or templates
$document->saveAs($fileTempPath.'.docx');

Expected Behavior

Open all the generated files on word (office)
Can use colors on both enviroments

Current Behavior

Some files are broken on word (office) && no colors (withSetComplexValue) on ubuntu

Context

Please fill in your environment information:

  • PHP Version: 7.2
  • PHPWord Version: 0.16.0
  • Libre office on ubuntu: LibreOffice 6.0.7.3 00m0(Build:3)

Maybe some preg_match can resolve the issues? Someone pass for it too?

PS.: Template processor is awesome, but this problems are kind hard to fix.

@Gadeoli
Copy link
Author

Gadeoli commented Oct 15, 2019

Fixed:

  1. Generated word (Saveas) works on word if generated by wamp (windows ), but dont works if generated on ubuntu.
    Fix: use libreoffice to convert: docx to a new docx.
    The new docx open on word if generated by ubuntu.

Don't find which part of the code is broken the template, but the hack works great.

  1. Custom colors (with setComplexValue) dont show off if generated by ubuntu.
    Fix: Dont use '#' - HASH - on hexadecimal colors. Like:
    $inline = new TextRun();
    $inline->addText('xpto', [color=> 'FF0000']);
    $reportObject->setComplexValue('someMacroKey', $inline);

@Gadeoli Gadeoli closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant