Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Mar 04, 2024 1:12 pm

Hi, I have a project where I was using spiredoc and I generated a docx document with information.

Then I had to install spire.office because I needed to work with spire doc and spire pdf.

When doing this I am having a problem in the parts where I generate docx, the error appears: There is no such base style ("Normal") in the document generation, in the places where I established a specific style in the document.

The style is defined as follow:
ParagraphStyle style = new ParagraphStyle(document);
style.Name = "MyStyle";
style.CharacterFormat.FontSize = 9;
document.Styles.Add(style);

How can I fix it?

camilapm
 
Posts: 11
Joined: Mon Jan 29, 2024 11:55 am

Tue Mar 05, 2024 2:59 am

Hello,

Thank you for your inquiry.

Please be advised that when a paragraph references a custom paragraph style using "paragraph.ApplyStyle(style.Name)," the resulting file will not reference the base style "Normal." If you wish for the resulting file to reference the "Normal" style, please utilize the following code snippet to set the font style of the paragraph:
Code: Select all
 TextRange range = paragraph.AppendText("text.");
 range.CharacterFormat.FontSize = 9;

Should you require any further clarification or assistance, please feel free to reach out.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Doc