Currently there is no easy way to modify the properties of bookmarks and fields in the document. Think of providing API for easier manipulation.
For example, following is one of the easiest approached to change the target of hyperlinks:
var hyperlinkStarts = document
.EnumerateChildrenOfType<FieldCharacter>()
.Where(fc => fc.FieldCharacterType == FieldCharacterType.Start && fc.FieldInfo.Field is Hyperlink);
foreach (var fieldCharacter in hyperlinkStarts)
{
int indexOfCodeRun = fieldCharacter.Paragraph.Inlines.IndexOf(fieldCharacter) + 1;
Run hyperlinkCode = (Run)fieldCharacter.Paragraph.Inlines[indexOfCodeRun];
string oldUri = ((Hyperlink)fieldCharacter.FieldInfo.Field).Uri;
string newUri = "mailto:mail@mail.com";
hyperlinkCode.Text = hyperlinkCode.Text.Replace($"\"{oldUri}\"", $"\"{newUri}\"");
fieldCharacter.FieldInfo.UpdateField();
}
Run's default constructor creates it with Text = null. When document with such run is exported to PDF, NullReferenceException is thrown. Workaround: Create the Run and immediately set its Text property to string.Emtpy. Available in LIB Version 2018.1.423.
Applying LockAspectRatio to an image is not respected after opening the document in MS Word - the LockAspectRatio checkbox in the is not checked. An additional XML element (cNvGraphicFramePr) should be added so the UI can respect it.
When the RowSpan value is bigger than the available rows, a ArgumentOutOfRangeException is thrown while exporting the document.
Workaround: Change the value of RowSpan after importing:
foreach (var cell in document.EnumerateChildrenOfType<TableCell>())
{
while (cell.RowSpan > cell.Row.Table.Rows.Count)
{
cell.RowSpan--;
}
}
Add support for importing HTML with syntax <img style="width: 300px; height: 300px;" /> At the moment only HTML attributes are supported.
When the table borders are None, and each cell has custom set borders, when cells are merged, only borders of the cell that has <w:vMerge w:val="restart"/> are imported.
When importing documents containing pictures with references represented with the r:link attribute, ArgumentNullException is thrown.
This element serves as a frame and allows the element to be positioned as a floating element. More information about it is available in section 22.9.2.18 ST_XAlign (Horizontal Alignment Location) of Open Office XML.
DECLINED: Duplicate with - Implement support for Text Frame Properties.
In the current implementation, the parent of a hyperlink must be a paragraph. Otherwise, a NullReferenceException is thrown.
When inserting content in an empty paragraph, the styles applied to it are the default document styles. However, if the properties are present in the last paragraph symbol, the content should inherit them.
Workaround: Copy the properties of the marker after inserting the content:
run.Properties.CopyPropertiesFrom(paragraph.Properties.ParagraphMarkerProperties);
foreach (var section in this.document.Sections){ bool shouldInsert = false; foreach (var block in section.Blocks.ToList()) { var paragraph = block as Paragraph; if (paragraph != null && paragraph.ListId > -1) { shouldInsert = true; } else if (shouldInsert) { var paragraphToInsert = new Paragraph(this.document); paragraphToInsert.Spacing.LineSpacing = 1; paragraphToInsert.Spacing.LineSpacingType = HeightType.Exact; paragraphToInsert.Spacing.SpacingAfter = 0; block.BlockContainer.Blocks.Insert(section.Blocks.IndexOf(block), paragraphToInsert); shouldInsert = false; } }}