-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
List item values are missing from docx file while convert as HTML file #1462
Comments
Up to this. I encountered the same issue as well. |
same here |
I also face the same issue and found that "ListItemRun.php" is missing from the PATH "src\PhpWord\Writer\HTML\Element" which is causing the issue. I added the file and made the changes. I got the list value but was missing the bullet icon. I am currently trying to fix this issue. In the mean while if anyone want the file, please let me know |
+1 |
@vineetagarwal1981 I could use the listItemRun.php file if you could make it available please. Just the data with out the bullets is sufficient for my needs. Thanks, |
@bozzit Below is the file that you require. Place this file at the PATH "src\PhpWord\Writer\HTML\Element" Let me know if it's working for you |
@vschavala If you just want to convert html, I find it's better to convert with more specific tools. The main purpose of PHPWord is to compose a word document with PHP, but not convert between formats. |
Hi Yes thank you, If I have time I will attempt to make it output a unordered lists instead of the text within elements. at least I'm not loosing the text within the lists by adding this file. |
Same here. If I generate a word document like here I will get this file structure:
With HTML generated lists this:
So you can see there is no numbering.xml. And also if you try to use libreoffice to generate a pdf all lists are empty. |
@kristl78 #1462 (comment) |
@lubobill1990 thank u but this is unfortunately not enough. |
I've used the solution from @vineetagarwal1981 but modified it a bit.
|
I just install PHPWord using composer (6/8/2020) I also see the above problem (loss of list text) when attempting to convert a .docx to .html. |
Hi Could you provide a little more specifics for example in which php file did you place this code? |
Hello @PhoenixRising2015! |
Just create a file called. "ListItemRun.php" in PATH "src\PhpWord\Writer\HTML\Element" With that code in it or look up in this thread there is a link ti a ZIP file with the "ListItemRun.php" in it. |
Same here:
After converting to HTML file:
|
for anyone having this issue the solution by @tikumo works
Replace the function write() in src\PhpWord\Writer\HTML\Element\ListItemRun.php with the code above and it will transform any listItemRun into a li element, however there is no way to create the parent ul for the lists afaik so I modified the function and make every list item a separated list as a temporary solution. If anyone has any solution for making the ul elements please let me know |
What I ended up doing is:
Then created my own writer that extends AbstractWriter
Hope this points you @Lurtz963 in the right directions. |
I tried this solution but data-depth is always 0 and the rest of the attributes are empty |
My bad, forgot I had to implement, some of those methods for the other Attributes, and 0 is normal for depth if you don't have nested lists. Top level List is always 0.
|
After a bit of struggle I was able to implement a similar solution @bozzit , for some reason I couldn't use a custom writer (It throws the error that is not a valid writer) so I modified HTML writer. I let the files here in case someone wants to use it or make a better version. |
Thanks! Your code helped me)) I just added a loop to the function write in ListItemRun.php
|
It's been 6 years and In any case, I took @CaptBarbarossa's code and extended it to handle all types of elements in the
The If you're installing this package with composer (like I am), you can use the |
I have use the this fix and it really did help to add list tag to the list however there is no ul/ol tag is there a way to determin this and what is the best way of adding this?
|
/* Here is my code*/
$PHPWord = new \PhpOffice\PhpWord\PhpWord();
$PHPWordLoad = \PhpOffice\PhpWord\IOFactory::load($file);
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWordLoad, 'HTML');
$tmpfname = public_path('doczipfiles/temp.html');
$htmlWriter ->save($tmpfname);
The text was updated successfully, but these errors were encountered: