Allow clients to specify image width, flow, and alt text for images#56
Merged
shinjukunian merged 27 commits intoshinjukunian:masterfrom Apr 14, 2026
Merged
Conversation
This will properly escape reserved characters that appear in links (e.g. the ampersand) shinjukunian#24
This required adding a “settings.xml” file that contains the following important line: <w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/> Setting “compatibilityMode” to 15 indicates that this is a “modern” docx file. With that set, Word will not open the docx in “Compatibility Mode” and you will be able to use recent Word features. In order for the settings.xml file to be found, “document.xml.rels” now contains a reference to “settings.xml.” Lastly, “[Content_Types].xml” was edited so that it is more human-readable.
# Conflicts: # DocX/blank/word/_rels/document.xml.rels
Made `color` optional when creating an underline element. In addition, if the `underlineColor` attribute is present, it will be preferred over `foregroundColor` (if any). If neither is specified, the underline color will not be output explicitly.
# Conflicts: # DocX/AttributeElements.swift # DocX/DocXPageDefinition.swift # DocX/DocXWriting.swift # DocXTests/DocXTests.swift
To annotate a paragraph does that it becomes a real list item in Word, you can use the following new attributes: .listNumberingId .listNumberingLevel .listStyle The “listNumberingId” is the identifier for the definition in the generated numbering.xml file. The “listNumberingLevel” specifies the indent level (0-based). And “listStyle” determines what kind of decoration is used for the list item (e.g. decimal, or bullet).
Added four new attributes: .footnoteReferenceId .footnoteBodyId .endnoteReferenceId .endnoteBodyId To indicate a footnote cue, add the “.footnoteReferenceId” attribute with an integer value that serves as an identifier for the footnote. Then, for the paragraph(s) of the footnote body, add the “.footnoteBodyId” attribute with the same integer identifier. Anything tagges with the “.footnoteBodyId” will not be exported into the main document content. For endnotes, just use the other attribute pair.
Added a new class, DocXImageAttachment, which is a subclass of NSTextAttachment. This new class contains the following additional properties: - imageWidthFraction: the image width as a fraction of the text column width - imageFlow: specifies whether the image should be aligned left or right, with text flowing around it (when not specified, the image is centered and text does not flow around it) - imageDescription: the alt text for the image This is obviously a subset of the image layout feature set that Word offers, but it adds some much-needed flexibility with how this package deals with images.
Added a new class, DocXImageAttachment, which is a subclass of NSTextAttachment. This new class contains the following additional properties: - imageWidthFraction: the image width as a fraction of the text column width - imageFlow: specifies whether the image should be aligned left or right, with text flowing around it (when not specified, the image is centered and text does not flow around it) - imageDescription: the alt text for the image This is obviously a subset of the image layout feature set that Word offers, but it adds some much-needed flexibility with how this package deals with images.
This test was bad: due to a copy/paste error, we were reusing footnote IDs. This is a problem, as they are intended to be globally unique. To prevent this in the future, we now check to make sure that footnote/endnote reference IDs are globally unique. If not, DocX will throw an error during writing. I added another test, testWriteSections_duplicateFootnoteIdThrows, that tests this. Lastly, while looking at the OOXML, I discovered that we weren’t adhering to OOXML standards (though this didn’t result in an issue). Nevertheless, we now ensure that <w:pPr> is the first child of <w:p> when adding section breaks.
shinjukunian
requested changes
Apr 14, 2026
Owner
shinjukunian
left a comment
There was a problem hiding this comment.
Hi @andalman ,
This is great. Could you rebase this PR onto the master branch?
Cheers and thanks for your contribution
Contributor
Author
|
Done!
…On Apr 14, 2026 at 06:05:30, Morten ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Hi @andalman <https://github.com/andalman> ,
This is great. Could you rebase this PR onto the master branch?
Cheers and thanks for your contribution
—
Reply to this email directly, view it on GitHub
<#56 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXE3PVY4VHWPP5XCE4C5DL4VYZRVAVCNFSM6AAAAACXQGEPZWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHM2DCMBWGEYDEMRTGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
shinjukunian
approved these changes
Apr 14, 2026
Owner
|
thank you again for your contribution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a new class,
DocXImageAttachment, which is a subclass ofNSTextAttachment. This new class contains the following additional properties:imageWidthFraction: the image width as a fraction of the text column widthimageFlow: specifies whether the image should be aligned left or right, with text flowing around it (when not specified, the image is centered and text does not flow around it)imageDescription: the alt text for the imageThis is obviously a subset of the image layout feature set that Word offers, but it adds some much-needed flexibility with how this package deals with images.