You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when reading docx files, a Title is recognized by matching the styleId attribute of a paragraph instead of the actual "name" of the linked style.
The styleId unfortunately gets automatically localized by Word. E.g. if you have an English version of Word installed, the styleId for a H1 title is always "Heading1", if the same word file gets "re-saved" in Italian Word, that style gets automatically saved as Titolo1.
The actual "style name" (<w:name> in styles.xml) however is always "heading 1" no matter the language of Word. (Yes: ironically word translates the hidden id and doesn't translate the actually shown name)
Steps to Reproduce
find a foreign language docx file. You can help yourself by going to google advanced search, selecting a different language (like German) and searching for something while limiting the file type to docx, like query "Beispiel filetype:docx". Download some files, and check if one actually uses headings styles.
Also make sure the heading isn't also numbered (or you'll run into Word2007 Reader: Title not recognized when it's a list item #2421) DON'T SAVE YOUR FILE, or your word will translate the IDs!
PhpOffice\PhpWord\Reader\Word2007\AbstractPart::getHeadingDepth() currently relies on pattern matching a $paragraphStyle['styleName']. This isn't however the real Name of the style, but rather it's Id. A fix would be being able to actually load a style by id, and then match on the real name.
Please fill in your environment information:
PHP Version: 8.2
PHPWord Version: 1.1.0
The text was updated successfully, but these errors were encountered:
Describe the Bug
Currently when reading docx files, a Title is recognized by matching the
styleId
attribute of a paragraph instead of the actual "name" of the linked style.The
styleId
unfortunately gets automatically localized by Word. E.g. if you have an English version of Word installed, thestyleId
for a H1 title is always "Heading1", if the same word file gets "re-saved" in Italian Word, that style gets automatically saved asTitolo1
.The actual "style name" (
<w:name>
instyles.xml
) however is always "heading 1" no matter the language of Word. (Yes: ironically word translates the hidden id and doesn't translate the actually shown name)Steps to Reproduce
Also make sure the heading isn't also numbered (or you'll run into Word2007 Reader: Title not recognized when it's a list item #2421)
DON'T SAVE YOUR FILE, or your word will translate the IDs!
Expected Behavior
Output:
Current Behavior
Context
PhpOffice\PhpWord\Reader\Word2007\AbstractPart::getHeadingDepth()
currently relies on pattern matching a$paragraphStyle['styleName']
. This isn't however the real Name of the style, but rather it's Id. A fix would be being able to actually load a style by id, and then match on the real name.Please fill in your environment information:
The text was updated successfully, but these errors were encountered: