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 Aug 30, 2021 8:55 pm

Hi,

In c# I am saving an RTF to DOCX. Using

var spireDoc = new Spire.Doc.Document();
spireDoc.LoadRtf(@"c:\temp\" + TempOverFileName);
spireDoc.SaveToFile(@"c:\temp\" + OverFileName, Spire.Doc.FileFormat.Docx);

But I'm finding it is adding a Section Break at end of document when it is saving (and so there is a blank page at the end of the document). Please see attached rtf and docx version of the file.

Although the section break doesn't appear on the RTF document, I've tried removing all breaks in the document using the following code between the load and the save:

for (int j = 0; j < spireDoc.Sections[0].Paragraphs.Count; j++)
{
Spire.Doc.Documents.Paragraph p = spireDoc.Sections[0].Paragraphs[j];
for (int i = 0; i < p.ChildObjects.Count; i++)
{
var obj = p.ChildObjects[i];
if (obj.DocumentObjectType == Spire.Doc.Documents.DocumentObjectType.Break)
{
Spire.Doc.Break b = obj as Spire.Doc.Break;
p.ChildObjects.Remove(b);
}
}
}

But either with or without this code, a Section Break (New Page) is being added to the end of the document.

Many thanks for any assistance that can help remove this Section Break.

phileviid
 
Posts: 1
Joined: Mon Aug 30, 2021 8:16 pm

Tue Aug 31, 2021 3:33 am

Hello,

Thanks for your inquiry.
I tested your case with the latest Spire.Doc Pack(hot fix) Version:9.8.6, but I did not reproduce your issue. If you are using an older version, we recommend you upgrade to the latest version and try it again.
If the issue persists after trying, please tell us your project target framework (e.g. .NET Framework 4.5) and your OS information (e.g. Windows7, 64bit). Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Sep 08, 2021 10:21 am

Hello,

Greetings from E-iceblue!
How is your issue now? Could you please give us some feedback at your convenience?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc