Added new example to show how to add image to Word document. It's also available as part of blog http://evotec.pl/docx-add-image-to-microsoft-word-document-programmatically/
Changed some solution settings to make sure it works with AnyCpu.
Fixed the problem with setting the column width for the whole table.
Without this patch the SetColumnWidth method throws the
NullReferenceException if the column widths haven't been initialized
before. Added the test to check the issue and to see whether it's fixed.
Chnaged 15 to 20 multiplier in margins and page size so that margins and page size are effectively set/retrieved in points (pts). This is a breaking change potentially, but otherwise it is not clear what the units are for page width, height, and margins.
- added a whole bookmarks collection so one can access it from DocX and get the bookmark by name
- added a SetText method to the Bookmark so one can set the text from it using something like this: docX.Bookmarks["MyBookmark"].SetText("MyText")
- Added example BookmarksReplaceTextOfBookmarkKeepingFormat
- MergeCellsInRow - allow for merging the rows where the columns don't match (for instance, merge the last column of a row with 6 elements and a row with 3 elements will merge the last column of the row with too few elements)
- this is a specific case that I needed... others may need it as well, but I've got a separate branch with this change so it's up to you
Container.cs (and baseclasses)
- Moved PackagePart to the base class - found an issue where images in a table contained in the header or footer wouldn't display, this keeps track of what part of the doc and passes it to child things, (like inserting a table to a paragraph in the footer will have the correct part)
- Add a deep search for paragraphs.. This is to find a bookmark within a textbox or other art.. since a paragraph will wind up with a child paragraph.. (if you are searching for a bookmark like that the second one is the "right" one)
Few changes were made to allow to set the column widths for a table, on table level instead for each single cell.
The following methods/properties have been added:
- ColumnWidths - Returns a list (Of Double) with the width of all columns
- GetColumnWidth - Returns the width to a given single column index
- SetColumnWidth - Sets the column width to a given index
Property "AutoFit" has been modified to use the fixed table width; AutoFit will be set to "Fixed" if method "SetColumnWidth" is called.
Furthermore the enumeration: "AutoFit" got an addtional value: "Fixed".
Some warnings:
If you apply a width on table level; the cell width value will be removed for all table cells!
This one is a performance boost for cases where docs have lots of paragraphs inserted (through tables or whatever)...
In the case that I found the issue, I was creating a report that added a lot of plain text paragraphs followed by lots of tables.. (creating a 40 page doc)
(the fix is to avoid using the Paragraphs collection to get the one that was just added.. it fixes the reference to the "mainPart" so things like images that are added still work... )
All unit tests pass after this test (did have to fix some case issues with the one that does text replacements though)
Includes:
-fix for default column widths (also works when column widths are not specified) - issue that was breaking tables with more than 14 cols
-New table method to set the widths for variable row tables... you can call Table.SetWidths(float [] yourWidthsInPixels) then for each row added those cols will have that width applied.. can help clean up some code.. also caches the column count for performance..
- Change for DocX that turns on zip compression for the parts of the doc (created docs are as small as re-saved versions from word now)
- "Keep With Next"
- "Keep Lines Together"
Also fixes an issue with:
- SpacingBefore
- SpacingAfter
Also 2 examples for Keep With Next and Keep Lines Together added into Exampels.
Patch provided by someotherdevguy. Thanks!