Problems with styles when working with OpenOffice Writer

Hello Aspose

I have some troubles with paragraph styles when working with OOo Writer.

  1. When saving an Aspose.Words document in OpenDocument format, heading styles are not assigned correctly. A paragraph defined as “Heading 1” in Aspose.Words is displayed correctly as “Heading 1” in Writer; however, it does not have Heading 1 font attributes, it is formatted in default style. Only after applying “Default Formatting” manually in Writer (i.e., after resetting local formatting), the paragraph shows up correctly in Heading 1 style.
  2. I generate an RTF file in Aspose.Words and copy it to the clipboard. When I paste this RTF in Writer, the “Heading 1” style of Aspose.Words is pasted as “heading 1” (in lowercase), which for Writer is a different style than “Heading 1”. Additionally, the problem described above also arises when exchange data via the clipboard.

Thank you in advance for your help,
Thomas

Hi Thomas,

Thanks for your request.

  1. Please attach sample documents here for testing. I will check the problem on my side and provide you more information.

  2. Is this the same problem as you have described in other your thread?

If not, please attach sample documents and provide me instruction, how to reproduce the problem.
https://forum.aspose.com/t/84759

Also, which version of Aspose.Words do you use?

Best regards.

Hi Alexey

  1. I save an Aspose.Words document in two formats, docx and odt. The docx result is what I want (see DOCXHeading1.png).
    When I open the odt file in Writer, Heading 1 is defined correctly as Segoe UI Bold 14 pt. However, the paragraph “Journals” has a font size of 9 points (see ODTHeading1.png). Please find the odt file produced by Aspose.Words attached.
  2. It is a different problem than the one in my first posting because it concerns Writer, not Word. However, it is the same problem in the sense that it has turned out to be a Writer bug (as the first posting was a Word bug). The incorrect “heading 1” style (in lowercase) also appears when saving a Writer document as RTF, copying this RTF to the Clipboard and pasting it to a blank Writer document. Sorry again for bothering you with bugs outside of your product.

Best regards,
Thomas

Hi Thomas,

Thank you for additional information. But you have attached only output ODT document. I also need your input document and code, which will allow me to reproduce the problem. I will try to replicate the issue and provide you more information.

Best regards.

Hello

You can reproduce the problem with the following code:

var doc = new Document();

foreach (Section section in doc.Sections) section.PageSetup.PaperSize = PaperSize.A4;

var normalStyle = doc.Styles[StyleIdentifier.Normal];
normalStyle.Font.Name = "Segoe UI";
normalStyle.Font.Size = 9;
normalStyle.ParagraphFormat.TabStops.Add(80, Aspose.Words.TabAlignment.Left, TabLeader.None);
normalStyle.ParagraphFormat.SpaceAfter = 6;

var defaultParagraphStyle = doc.Styles[StyleIdentifier.DefaultParagraphFont];
defaultParagraphStyle.Font.Name = "Segoe UI";
defaultParagraphStyle.Font.Size = 9;

var heading1 = doc.Styles[StyleIdentifier.Heading1];
heading1.Font.Name = "Segoe UI";
heading1.Font.Size = 15;
heading1.ParagraphFormat.SpaceAfter = 24;

var builder = new DocumentBuilder(doc);

builder.ParagraphFormat.Style = doc.Styles[StyleIdentifier.Heading1];
builder.Writeln("Journals");
builder.ParagraphFormat.Style = doc.Styles[StyleIdentifier.Normal];
builder.Writeln();

builder.Bold = true;
builder.Writeln("Regional anesthesia and pain medicine");
builder.Bold = false;
builder.ParagraphFormat.LeftIndent = 80;
builder.ParagraphFormat.FirstLineIndent = -80;
builder.Writeln(string.Format("{0}\t{1}", "References:", "Zellweger, Gunther et al. 2009 – Tumour growth fraction"));

builder.Bold = true;
builder.Writeln("Journal of feline medicine and surgery");
builder.Bold = false;
builder.ParagraphFormat.LeftIndent = 80;
builder.ParagraphFormat.FirstLineIndent = -80;
builder.Writeln(string.Format("{0}\t{1}", "References:", "Gerber 2008 – Guarded long-term prognosis"));

string filePath = @"";
doc.Save(filePath, SaveFormat.Odt);
System.Diagnostics.Process.Start(filePath);

The paragraph “Journals” will not be formatted in Segoe UI 15 pt, as defined in Heading 1, but in 9 pt.

Thanks,
Thomas

P.S. While experimenting with the above code, I see that the problem disappears when I don’t define the “DefaultParagraphFont”. Would that be a solution? What would the “DefaultParagraphFont” be for, then?

Thank you,
Thomas

Hi Thomas,

Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.

As a workaround you can avoid defining of DefaultParagraphFont style.

Best regards.

The issues you have found earlier (filed as 10785) have been fixed in this update.


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

Thank you!

Thomas