End of Paragraph character formatting

Hi Team,

The character marking at the end of paragraph now inherits the formatting from the text ahead of it in Aspose.Words For Java 14.5. This is not seen in 13.5.

I’ve attached sample code to replicate the issue along with the document. Please enable marking to see the difference.

Thanks,
Kumar

public static void main(String a[]) throws Exception
{
System.out.println(“Aspose product and version is = " + BuildVersionInfo.getProduct() + " : " + BuildVersionInfo.getVersion());
setupLicense();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln();

builder.getFont().setSize(24);
builder.getFont().setColor(Color.GREEN);
builder.getFont().setBold(true);
builder.write(“Bold text”);

builder.clearRunAttrs();
builder.write(” non bold");

builder.writeln();
builder.writeln();

builder.getListFormat().applyBulletDefault();
builder.getFont().setColor(Color.BLUE);
builder.getFont().setBold(true);
builder.getFont().setSize(30);
builder.write(“list item 1”);
builder.clearRunAttrs();
builder.writeln();

builder.getFont().setColor(Color.BLUE);
builder.getFont().setBold(true);
builder.getFont().setSize(30);
builder.write(“list item 2”);
builder.clearRunAttrs();
builder.writeln();

builder.getFont().setColor(Color.BLUE);
builder.getFont().setBold(true);
builder.getFont().setSize(30);
builder.write(“list item 3”);
builder.clearRunAttrs();

String docpath = new File(System.getProperty(“java.io.tmpdir”), “testEndOfLine_” + BuildVersionInfo.getVersion() + “.doc”).getAbsolutePath();

doc.save(docpath);

System.out.println("Result: " + docpath);
}

The other issue is “List numbering takes styling of the list content”. This is not seen in earlier version.

Adding the following code after clearRunAttrs() fixes the issue. Why is it so? Is this recommended? Is this a regression in the newer version?

builder.getCurrentParagraph().getParagraphBreakFont().clearFormatting();

Hi Team,

Could someone take a look at this please? It’s a bit urgent.

Thanks,
Kumar

Hi Kumar,

Please accept my apologies for late response.

Thanks for your inquiry.

kumaraswamy.m:

The character marking at the end of paragraph now inherits the formatting from the text ahead of it in Aspose.Words For Java 14.5. This is not seen in 13.5.

I have tested the scenario and have not found any issue with output document using latest version of Aspose.Words for Java 14.8.0. In this case, the behavior of latest version of Aspose.Words is correct. I suggest you please use Font.clearFormatting method instead of clearRunAttrs.


Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln();

System.out.println(builder.getCurrentParagraph().getParagraphBreakFont().getSize());

builder.getFont().setSize(24);

System.out.println(builder.getCurrentParagraph().getParagraphBreakFont().getSize());

builder.getFont().setColor(Color.GREEN);

builder.getFont().setBold(true);

builder.write("Bold text");

builder.getFont().clearFormatting();

builder.write(" non bold");

builder.getCurrentParagraph().getParagraphBreakFont().clearFormatting();

System.out.println(builder.getCurrentParagraph().getParagraphBreakFont().getSize());

builder.writeln();

builder.writeln();

kumaraswamy.m:
Hi Team,
Adding the following code after clearRunAttrs() fixes the issue. Why is it so? Is this recommended? Is this a regression in the newer version?

builder.getCurrentParagraph().getParagraphBreakFont().clearFormatting();

Yes, ParagraphBreakFont.clearFormattingthis resets to default font formatting. This is not a bug. Note that Paragraph.ParagraphBreakFont property provides access to the font formatting of the paragraph break character.
kumaraswamy.m:

The other issue is “List numbering takes styling of the list content”. This is not seen in earlier version.

Could you please share some more detail about this query?

Hi Tahir,

I see the same behavior (issues) with 14.8 as well. Using Font.clearFormatting() doesn’t help.

Issue 1: End of paragraph formatting
Issue 2: Bullets take same color as text.

Please see attached screenshot for better understanding.

The code pasted in thread 1 works good in 13.5, but the formatting is affected in 14.5. Why is there a change in behavior across version for the same piece of code? Is this is regression?

Thanks,
Kumar

The screenshot is bit incorrect. Please refer to the attached documents in the first thread.

Hi Kumar,

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Tahir,

I don’t understand why would you need a manually created word document as I’ve already attached in the first thread. I just want the word document as when I create using Aspose.Words for Java 13.5.

The blue document below is expected and the one in red is incorrect.

testEndOfLine_13.5.0.0.doc vs testEndOfLine_14.5.0.0.doc

Let me know if you need anything more to investigate.

Thanks,
Kumar

Hi Kumar,

Thanks for sharing the detail.

The output document generated by using Aspose.Words for Java 14.8.0 with following code example is correct. The document is generated according to the code. Please check the attached document and image output-14.8.0.png. If you create the same document using MS Word with same text and formatting, you will get the same output. The older version of Aspose.Words (v13.5.0) generates the incorrect document.


Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln();

builder.getFont().setSize(24);

builder.getFont().setColor(Color.GREEN);

builder.getFont().setBold(true);

builder.write("Bold text");

builder.getFont().clearFormatting();

builder.write(" non bold");

//builder.getCurrentParagraph().getParagraphBreakFont().clearFormatting();

builder.writeln();

builder.writeln();

builder.getListFormat().applyBulletDefault();

builder.getFont().setColor(Color.BLUE);

builder.getFont().setBold(true);

builder.getFont().setSize(30);

builder.write("list item 1");

builder.getFont().clearFormatting();

builder.writeln();

builder.getFont().setColor(Color.BLUE);

builder.getFont().setBold(true);

builder.getFont().setSize(30);

builder.write("list item 2");

builder.getFont().clearFormatting();

builder.writeln();

builder.getFont().setColor(Color.BLUE);

builder.getFont().setBold(true);

builder.getFont().setSize(30);

builder.write("list item 3");

builder.getFont().clearFormatting();

doc.save(MyDir + "Out.docx");


Hi Tahir,

1. Why is end of line marker in green and size 30 in the first line in your screenshot? It should be black and the font size should be default.
– I tried the same in MS Word and I see output as generated by Aspose 13.5.
2. When you start the list, not color is set and not for bullets too. The default color is black. Before writing the text, the color is set. Why does the color gets applied to the bullets too?
– I tried the same in MS Word and I see output as generated by Aspose 13.5.

See screenshot if above statements are not clear.

Thanks,
Kumar

Hi Kumar,

Thanks for sharing the detail. I have logged this problem in our issue tracking system as WORDSNET-10765. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-10765) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.