[C#][Original] aspose.word delete document blank lines

The following code test passes, but aspose.word has a shortcoming. After the document is loaded, the line spacing will automatically change from single line spacing to 1.15 multiple line spacing. After the paragraph, the original 0 result will become 10. Can't find a good solution at present, if you know the solution, let’s talk together        

 

 

 

public void RemoveEmpyLines(string docFile, string saveFile)
        {

            Document doc = new Document(docFile);
  
            //Traverse the document, determine whether the paragraph contains blank lines, delete the blank lines
            foreach (Section section in doc.Sections)
            {                 for (int i = 0; i <section.Body.ChildNodes. Count; i++)                 {                     if (section.Body.ChildNodes[i].NodeType == NodeType.Paragraph)                     {
    


               


                       

                        if (String.IsNullOrEmpty((section.Body.ChildNodes[i] as Paragraph).GetText().Trim()))
                        {
                            section.Body.ChildNodes.Remove(section.Body.ChildNodes[i]);
            
                            i--;
                        }
                    }
                }
            }        
            doc.Save(saveFile);
        }

Guess you like

Origin blog.csdn.net/FL1623863129/article/details/112967780