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

Didn't give up on PHPWord, decided to add to it. =) Hope this helps. #625

Open
WriterStat opened this issue Sep 24, 2015 · 6 comments
Open

Comments

@WriterStat
Copy link

WriterStat commented Sep 24, 2015

Ok the post below was done yesterday, but after realizing what was going on, I decided to add to PHPWord, build on the good work and add in what I needed, read the post after this one....left the post below as a sign post for others in the same situation...

Help! I was excited to use this. I set it up, I pass in html using the provided html example as a guide. I checked the html to make sure it's legal/good.

And well...I check out the word doc that should be created...and well...not much but plain text is in it. =\

No bold. It doesn't center justify, centered text. Just basically plain text is showing up in the word doc on the left. No underline or strikethrough.

If you put italicized or bold or anything in a list, the words disappear. If you bold anywhere, no bold appears.

I used the settings config as in the html example.

I have a small list of things I need, bold, italicized, strikethrough, underline, simple list, justification, left and center.

Basically that's it.

But even though the html shows it, the word doc, does not. The word doc just shows plain text all left justified. It does however show a simple bullet list in the word doc. It gets the bullet list for some reason. But none of the other above stuff.

What am I doing wrong? What's the trick? Thanks! Possible I don't understand what I'm doing. =)

A few pointers where the above from html things works. And I'll do the rest.

Here's some test html:

<div style="text-align: center;"><span style="font-size: 16px;font-family: 'Droid Sans';"><u>Chapter 2</u></span></div><div style="text-align: left;"><br /></div><div><b>Go</b></div><ul><li><i>asas</i></li><li><b>saas</b></li><li><s>aas</s></li><li>as</li></ul><div><span style="background-color: rgb(255, 153, 0);">ssss</span></div>

Doesn't seem to understand any of the html above. I've tried the different variations, css, html tags.

Does reading in html work? My apologies if it doesn't. I'm using the newest master version.

I really want to like this and have it work. So any help from any one is much appreciated.

I like you guys and I know it's not easy. Not asking you to do it. Don't need to do it for me, I'll do it, just point me in the right direction. Get a start on the above html, I've tried inline css, I've tried tags for bold. And the others etc...

Tried to post some test html I'm using here, I've used both the css for bold and the bold tag.

I'm using the configuration settings from the html example.

Again it could be all my fault.

Cheers,

Before I pull the plug on this. Should be easy, instantiate, read in the html, create the doc.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@WriterStat WriterStat changed the title Help? Starting to give up on PHPWord, need help. It's doesn't bold, it doesn't center, it removes words inside lists if you italicize them. Help? Help? Starting to give up on PHPWord, need help. It doesn't bold, it doesn't center, it removes words inside lists if you italicize them. Help? Sep 24, 2015
@WriterStat
Copy link
Author

It looks as though PHPWord doesn't understand html divs.

If you take the html reading in example provided and change one line from starting with <p> to <div> things get a bit wild, stop working correctly. Could be my problem above.

@WriterStat WriterStat changed the title Help? Starting to give up on PHPWord, need help. It doesn't bold, it doesn't center, it removes words inside lists if you italicize them. Help? Didn't give up on PHPWord, decided to add to it. =) Hope this helps. Sep 24, 2015
@WriterStat
Copy link
Author

Hi all! Once I realized the problem, I realized I had to dig in and that the PHPWord team and all the contributors had done a fine job of putting the framework together for me to do that.

Hats off and kudos to everyone for putting in the effort of building a fine framework.

At first I thought well I'll just filter and replace what doesn't work with what does. But that got to be a little much. That's when I ran into the HTML.php and realized the framework was there, I just needed to add to it.

Building on the fine framework here, I've added support for <div> based on support for <p>, then I added <u>(underline), <s>(strikethrough), <i>(italics) and some others.

Now I'm working on the css things like text background colors and text colors. some of that code is there, but didn't seem to be working for me.

Thanks to the PHPWord team for putting together a fine framework. Let me know if I can post these changes back in. They are small changes.

I may still need some help with applying the above inside lists, as they make the text in lists disappear. But I'm sure we'll get it sooner or later. Thanks for listening. -C

@alexvanniel
Copy link

@WriterStat : As I am trying to get PHPWord to read and construct HTML from a docx, I am very curious as to where you got with this. Is there any code I could look at, maybe even help you with this? I feel there is potential in the PHPWord package, but the HTML writer really lacks functionality I require and actually is missing from all docx reader/writers out there. Even the very expensive PHPDocX package is unable to construct proper HTML from DocX documents.

@WriterStat
Copy link
Author

WriterStat commented Mar 19, 2016

Hey Alex thanks for the note. We should exchange contact info some way. I got it to a point where it's partially working the way I want, just enough so I could move on to other more pressing matters.

But would be cool to expand upon it a bit.

Get the gate to flow both ways. Import docx to html.

Our goal was to get the export of html to a docx file.

The import/export is actually quite doable if you have the right parser and have read the Docx coding/encoding docs for the current microsoft word version.

Cheers

@portbury
Copy link

portbury commented Apr 28, 2016

hey @WriterStat I'm wondering if you had any luck getting em and b tags working when they are in lists? I have items in a <ul> but parts enclosed in an <em> tag are disappearing for me as well.

@WriterStat
Copy link
Author

WriterStat commented Apr 28, 2016

Hi! Have had some luck, but got called away on another project. So haven't looked at this for a bit.

Let me know what you have tried so far, so i don't duplicate it. It's either in the Parser or Writer for PHPWord and html/word2007.

Most likely in the HTML Parser. I'd track it down step by step. You can find this starting under Shared/Html.php. I'd make sure first that it's a two pass parser. Meaning that we know it gets the <ul></ul> and <li></li> tags on the first pass, but possibly errors out on the tags inside it.

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

3 participants