using
Spire.Doc;
using
Spire.Doc.Documents;
using
Spire.Doc.Fields;
using
System;
using
System.Collections.Generic;
using
System.Drawing;
using
System.Linq;
using
System.Text;
namespace
insert_new_paragraph_and_hide
{
class
Program
{
static
void
Main(
string
[] args)
{
Document document =
new
Document();
document.LoadFromFile(
@"C:\Users\Administrator\Desktop\向日葵.docx"
, FileFormat.Docx);
Paragraph paraInserted = document.Sections[0].AddParagraph();
TextRange textRange1 = paraInserted.AppendText(
"向日葵的花语是――太阳、光辉、高傲、忠诚、爱慕、沉默的爱。向日葵又叫望日莲,一个很美的名字"
);
textRange1.CharacterFormat.TextColor = Color.Blue;
textRange1.CharacterFormat.FontSize = 15;
textRange1.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash;
document.SaveToFile(
"result.docx"
, FileFormat.Docx);
Document doc =
new
Document();
doc.LoadFromFile(
@"C:\Users\Administrator\Desktop\雏菊.docx"
, FileFormat.Docx);
Section sec = doc.Sections[0];
Paragraph para = sec.Paragraphs[sec.Paragraphs.Count - 1];
for
(
int
i = 0; i < para.ChildObjects.Count;i++)
{
(para.ChildObjects[i]
as
TextRange).CharacterFormat.Hidden =
true
;
}
doc.SaveToFile(
"result1.docx"
, FileFormat.Docx);
}
}
}