foreach (Section section in doc.Sections)
{
foreach (Paragraph paragraph in section.Paragraphs)
{
paragraph.Format.BeforeSpacing = 0;
paragraph.Format.AfterAutoSpacing = false;
paragraph.Format.AfterSpacing = 0;
paragraph.Format.BeforeAutoSpacing = false;
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Justify;
}
foreach (DocumentObject obj in section.Body.ChildObjects)
{
if (obj is Paragraph)
{
var para = obj as Paragraph;
foreach (DocumentObject Pobj in para.ChildObjects)
{
if (Pobj is TextRange)
{
TextRange textRange = Pobj as TextRange;
textRange.CharacterFormat.FontName = "Calibri";
textRange.CharacterFormat.FontSize = 10;
}
}
}
}
foreach (Spire.Doc.Table table in section.Tables)
{
foreach (Spire.Doc.TableRow row in table.Rows)
{
foreach (Spire.Doc.TableCell cell in row.Cells)
{
foreach (Paragraph p in cell.Paragraphs)
{
foreach (DocumentObject Pobj in p.ChildObjects)
{
if (Pobj is TextRange)
{
TextRange textRange = Pobj as TextRange;
textRange.CharacterFormat.FontName = "Calibri";
textRange.CharacterFormat.FontSize = 10;
}
}
p.Format.BeforeSpacing = 0;
p.Format.AfterAutoSpacing = false;
p.Format.AfterSpacing = 0;
p.Format.BeforeAutoSpacing = false;
p.Format.HorizontalAlignment = HorizontalAlignment.Justify;
}
}
}
}
foreach (DocumentObject obj in header.ChildObjects)
{
section.HeadersFooters.Header.ChildObjects.Add(obj.Clone());
}
foreach (DocumentObject obj in footer.ChildObjects)
{
section.HeadersFooters.Footer.ChildObjects.Add(obj.Clone());
}
}