Aspose.Words for .NET 19.4 Release Notes

Major Features

  • Added a new ImportFormatOptions class for more flexible control over importing tasks.
  • Provide API to change how text is vertically aligned within the Text Box.
  • Added a new ImportFormatOptions.KeepSourceNumbering option for use in import operations.
  • Added a new ImportFormatOptions.IgnoreTextBoxes option for use in import operations.
  • Added property PdfSaveOptions.AdditionalTextPositioning to control writing of additional text positioning operators in PDF.
  • Implemented processing of fonts with “_GB2312” name suffixes (e.g. “KaiTi” font) when rendering metafiles.
  • Improved calculation of extrema when rendering DrawingML charts.
  • Improved vertical axis scaling of the chart with a manual layout of the plot area when rendering.
  • Improved impact assessment of the chart title size on the vertical axis scaling when rendering.
  • Improved vertical axis scaling when rendering DrawingML charts with the specified legend and the manual layout of the plot area.
  • Fixed a bug that caused a violation of PDF A-1b compliance when writing large text position adjustment values.
  • Fixed a bug with calculating extremums of the vertical axis when rendering DrawingML charts.
  • Fixed a bug with exception when converting a radar chart with empty Y-values to PDF.
  • Fixed a bug with rendering of transparent shapes with line caps specified.
  • Fixed infinite loop when shape overlapping is computed.
  • Improved shading rendering for condensed text.
  • Improved overlapping logic for frames and tables.
  • Improved Keep With Next rule handling for paragraph splits.
  • Improved Keep Lines Together rule handling in presence of floaters.

Full List of Issues Covering all Changes in this Release

KeySummaryCategory
WORDSNET-14095Add a border to a DML shapeNew Feature
WORDSNET-18027DOCX to PDF - additional gaps between characters in the printed textNew Feature
WORDSNET-17996Provide API to change how text is vertically aligned within the Text BoxNew Feature
WORDSNET-17534NodeImporter. ListFormat not importedBug
WORDSNET-18107Document.Save method does not stop while saving DOCX to PDFBug
WORDSNET-18130Vertical container bounds for shapes in compatibility modeBug
WORDSNET-9890TextBox with vertical text in Header is not preserved in PDFBug
WORDSNET-15523Image missing when converting .docx to .pdfBug
WORDSNET-17951Font formatting of Empty Paragraph is not preserved after DOCX->HTML->DOCX conversionBug
WORDSNET-18189DocumentBuilder.insertHtml inserts extra space just before line breakBug
WORDSNET-18231Aspose.Words.FileCorruptedException is thrown while loading DOCBug
WORDSNET-18296System.NullReferenceException occurs upon converting DOC to PDFBug
WORDSNET-17894Images with the absolute path but no scheme are not savedBug
WORDSNET-18363The content of the comments can’t be highlighted in some casesBug
WORDSNET-18263System.IndexOutOfRangeException is thrown while saving DOCX to HTML/PDFBug
WORDSNET-17821Incorrect scaling of the second vertical axis after conversion to PDFBug
WORDSNET-18065UpdateFields throws ‘Requested default value for an unknown attribute’ exceptionBug
WORDSNET-18110Characters are overlapped after conversion from RTF to PDFBug
WORDSNET-18143DOCX to HTML to DOC - “behind text” shape is positioned behind text because blank lines are removedBug
WORDSNET-18230DOCX to PDF conversion issue with Chinese text renderingBug
WORDSNET-18159ShapeRenderer crashes when rendering Emoji on macOSBug
WORDSNET-17961Replacement of text produces duplicated text linesBug
WORDSNET-14740AW does not split a paragraph to satisfy “keep with next” ruleBug
WORDSNET-18016Aspose.Words.FileCorruptedException is thrown while loading HTMLBug
WORDSNET-18220Incorrect shape position on conversion to fixed page formatsBug
WORDSNET-18281Update Aspose.TestBenchmark to the latest BenchmarkDotNet libraryBug
WORDSNET-17255Page field returns incorrect value (wrong document layout)Bug
WORDSNET-18115DOCX to PDF - content moved to next pageBug
WORDSNET-18390The first page is missing when saving ODT fileBug
WORDSNET-18136Style property for items starting with 10 is absent when we include the fontBug
WORDSNET-14974The slope of Drawing Line is incorrect after conversionBug
WORDSNET-10664MSWord2013 can split a table row due to “Keep with next” optionBug
WORDSNET-11824Paragraph rules are not applied to paragraphs inside cellsBug
WORDSNET-13063The paragraph does’ t apply “keep lines together” ruleBug
WORDSNET-18266System.OverflowException is thrown while loading MHTMLBug
WORDSNET-17868The range of Y-Axis of the chart is changed in output PDFBug
WORDSNET-17862Text overlapping in rendered PDFBug
WORDSNET-17901The vertical axis gets the incorrect interval scaling in PDF outputBug
WORDSNET-18198The textbox is improperly aligned after HTML round tripBug
WORDSNET-18005Document.Save throws System.NullReferenceException at UbuntuBug
WORDSNET-18205The equation is converted to the image in DOCX outputBug
WORDSNET-18086Add support for .ICO files with PNG images insideBug
WORDSNET-18197InsertImage throws System.NullReferenceException when SVG is inserted into DocumentBug
WORDSNET-18319Aspose.Words.FileCorruptedException is thrown while loading DOCXBug
WORDSNET-17526Process hangs during DOCX to PDF conversionBug
WORDSNET-17939Strange code in DmlChartPlaneCartesian3D classBug
WORDSNET-17952Document.UpdateFields throws System.NotSupportedExceptionBug
WORDSNET-18215“width” of HTML cells specified in percents is ignored if “min-width” is also presentBug
WORDSNET-18274UpdateFields() method does not finishBug
WORDSNET-14397Inserting documents does not preserve numberingBug
WORDSNET-18265NodeImporter.ImportNode throws exception after UpdatePageLayoutBug
WORDSNET-17544Table borders in fixed-page HTML disappear in Chrome at lower zoom levelsBug
WORDSNET-18095Table Cell Line Spacing lost when converting to PDFBug
WORDSNET-17866Incorrect rendering of Axis labels after converting to PDFBug
WORDSNET-18320Aspose.Words.FileCorruptedException is thrown while loading DOCXBug
WORDSNET-18279Header and Footer are lost after re-saving DOCBug
WORDSNET-17083InsertDocument inserts a white space at the start of the contentBug
WORDSNET-17504The section break is lost after DOCX>HTML>DOCX conversionBug
WORDSNET-18392PDF A-1b compliance validation issuesBug
WORDSNET-11660Table objects in MS Word are not shown in PDF renditionBug
WORDSNET-18202Problems with NodeImporter using ImportFormatMode KeepSourceFormattingBug

Public API and Backward Incompatible Changes

This section lists public API changes that were introduced in Aspose.Words 19.4. It includes not only new and obsoleted public methods, but also a description of any changes in the behavior behind the scenes in Aspose.Words which may affect existing code. Any behavior introduced that could be seen as regression and modifies the existing behavior is especially important and is documented here.

Added a new ImportFormatOptions class for more flexible control over importing tasks

Related issue: WORDSNET-14397 has now been resolved.

Added a new ImportFormatOptions class with only a single public property SmartStyleBehavior:

/// <summary>
/// Allows to specify various import options to format output.
/// </summary>
public class ImportFormatOptions
{
  /// <summary>
  /// Smart style behavior.
  /// Default value is <c>false</c>.
  /// </summary>
  public bool SmartStyleBehavior
}

This option starts working when styles clashes upon importing. 

 When this option is enabled, a source style will be expanded into direct attributes inside a destination document, if KeepSourceFormatting importing mode is used. 

 When this option is disabled, a source style will be expanded only if it is numbered. Existing destination attributes will not be overridden, including lists. 

 For a moment this option can be used only with a new public method of a DocumentBuilder class:

/// <summary>
/// Inserts a document at the cursor position.
/// </summary>
public Node InsertDocument(Document srcDoc, ImportFormatMode importFormatMode, ImportFormatOptions options)

UseCase:

Document srcDoc = new Document("source.docx");
Document dstDoc = new Document("destination.docx");
DocumentBuilder builder = new DocumentBuilder(dstDoc);
builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.PageBreak);
ImportFormatOptions options = new ImportFormatOptions();
options.SmartStyleBehavior = true;
builder.InsertDocument(srcDoc, ImportFormatMode.UseDestinationStyles, options);

Changes in font resolving while loading HTML (SVG) document

Related issue: WORDSNET-17383 has now been resolved:

Previously while loading HTML (SVG) document font families resolved by font names were found on the system. 

 If font family wasn’t found on the system original font family kept in the model. 

 This led to a situation when resolved font name depended on the local system. 

 For example, if ‘UnknownFont1’ is absent on the system the following font family declaration resolved as ‘Arial’ (‘Arial’ is name for ‘san-serif’ generic font name.)

<p style='font-family:UnknownFont1, sans-serif;'>This is a paragraph.</p>

Now the customer can use font settings before loading the document (add substitution rule, specify fonts folder and etc). 

 The following example shows how to add font substitution rule while loading the document.

FontSettings fontSettings = new FontSettings();
TableSubstitutionRule substitutionRule = fontSettings.SubstitutionSettings.TableSubstitution;

// If "UnknownFont1" font family is not available then substitute it by "Comic Sans MS".
substitutionRule.AddSubstitutes("UnknownFont1", new string[] { "Comic Sans MS" });
LoadOptions lo = new LoadOptions();
lo.FontSettings = fontSettings;
Document doc = new Document(MyDir + "myfile.html", lo);

The resulting model will contain ‘UnknownFont1’ as resolved font name for a paragraph from example. 

API to change how text is vertically aligned within the Text Box

Related issue: WORDSNET-17996 has now been resolved.

Added new property for specifying vertical anchor of shape’s textbox.

/// <summary>
/// Specifies the vertical alignment of the text within a shape.
/// </summary>
/// <remarks>
/// <p>The default value is <see cref="TextBoxAnchor.Top"/>.</p>
/// </remarks>
public TextBoxAnchor VerticalAnchor
{
    get;
    set;
}

The property allows to specify text anchor within the shape (Top, Middle, Bottom).

Document doc = new Document(fileName);
Shape shape = doc.FirstSection.Body.Shapes[0];
shape.TextBox.VerticalAnchor = TextBoxAnchor.Middle;

Saving warnings will be thrown for unsupported formats (WordML) and for incompatible Word versions above 2007 (DOC, DOT).

Added public property PdfSaveOptions.AdditionalTextPositioning

Related issue: WORDSNET-18027 has now been resolved.

The following new property has been added into the PdfSaveOptions class:

/// <summary>
/// A flag specifying whether to write additional text positioning operators or not.
/// </summary>
/// <remarks>
/// <para>
/// If <c>true</c>, additional text positioning operators are written to the output PDF. This may help to overcome
/// issues with inaccurate text positioning with some printers. The downside is the increased PDF document size.
/// </para> 
/// <para>The default value is <c>false</c>.</para>
/// </remarks>
public bool AdditionalTextPositioning
{
    get { return mAdditionalTextPositioning; }
    set { mAdditionalTextPositioning = value; }
}

Added a new ImportFormatOptions.KeepSourceNumbering option for use in import operations

Related issue: WORDSNET-17534 has now been resolved.

When import nodes between different documents there can be a situation when source document has lists with the same identifiers that were already used in a destination document. Word in such case always uses formatting from the destination lists.

To allow users to choose an appropriate behavior, the following option was introduced in ImportFormatOptions class:

/// <summary>
/// Gets or sets a boolean value that specifies how the numbering will be imported when it clashes in source and destination documents.
/// The default value is <c>false</c>.
/// </summary>
public bool KeepSourceNumbering

Also, a new public method that accepts the new KeepSourceNumbering option was introduced as the following:

/// <summary>
/// Initializes a new instance of the <see cref="NodeImporter"/> class.
/// </summary>
/// <param name="srcDoc">The source document.</param>
/// <param name="dstDoc">The destination document that will be the owner of imported nodes.</param>
/// <param name="importFormatMode">Specifies how to merge style formatting that clashes.</param>
/// <param name="importFormatOptions">Specifies various options to format imported node.</param>
public NodeImporter(DocumentBase srcDoc, DocumentBase dstDoc, ImportFormatMode importFormatMode, ImportFormatOptions importFormatOptions)

UseCase:

Document srcDoc = TestUtil.Open(@"source.docx");
Document dstDoc = TestUtil.Open(@"destination.docx");
ImportFormatOptions importFormatOptions = new ImportFormatOptions();

// Keep source list formatting when importing numbered paragraphs.
importFormatOptions.KeepSourceNumbering = true;
NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting, importFormatOptions);
ParagraphCollection srcParas = srcDoc.FirstSection.Body.Paragraphs;
foreach (Paragraph srcPara in srcParas)
{
    Node importedNode = importer.ImportNode(srcPara, false);
    dstDoc.FirstSection.Body.AppendChild(importedNode);
}
dstDoc.Save("output.docx");

Added a new ImportFormatOptions.IgnoreTextBoxes option for use in import operations

Related issue: WORDSNET-18202 has now been resolved.

When import a text box between different documents, the formatting of the destination document is applied to it. This corresponds to the behavior of Word. To allow users to choose an appropriate behavior, the following option was introduced in ImportFormatOptions class:

/// <summary>
/// Gets or sets a boolean value that indicates whether to ignore formatting in the text boxes of
/// the source destination during the import.
/// Default value is <c>true</c>.
/// </summary>
public bool IgnoreTextBoxes

UseCase:

Document srcDoc = TestUtil.Open(@"source.docx");
Document dstDoc = TestUtil.Open(@"destination.docx");
ImportFormatOptions importFormatOptions = new ImportFormatOptions();

// Keep the source text boxes formatting when importing.
importFormatOptions.IgnoreTextBoxes = false;
NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting, importFormatOptions);
ParagraphCollection srcParas = srcDoc.FirstSection.Body.Paragraphs;
foreach (Paragraph srcPara in srcParas)
{
    Node importedNode = importer.ImportNode(srcPara, true);
    dstDoc.FirstSection.Body.AppendChild(importedNode);
}
dstDoc.Save("output.docx");