This article mainly solves two problems:
1: How to generate the content in html into a word document in php
2: php converts the content in html When generated into a word document, if the problem is not displayed in the center, it will be displayed in the web view by default.
3: When PHP generates content from HTML into a word document, related style incompatibility issues
Text:
If it is displayed according to the normal page view, you need to add a line of xml mark in the header for setting (blue code part):
As for the third problem, there are some style incompatibility issues, such as the underline annotation of relevant attributes under the big title at the top:
We added the border-bottom: 1px solid #545454; style (blue code part) to the style in html, that is: , but the underline is still not displayed because it is not recognized in word. As shown below:
The solution is to change it according to the subscript style recognized by word, that is: . After changing to this style, that is, after opening the word document downloaded to the local It will be underlined.
It is better to teach a man to fish than to teach him to fish. I will share with you my solution to this style incompatibility:
1: Find a web version of the online editor, then enter a few words in it, and then add an underline
2: Then click the view source code button on the editor, you can see that the underlined attribute just added is text-decoration: underline; instead of the style mark in html: border-bottom: 1px solid # 545454;
Okay, that’s it for the above related issues. If you have any questions, please ask them and we will discuss and solve them together.