使用spire.doc更改整个word文档的字体样式和大小

时间:2015-03-29 15:22:03

标签: visual-studio-2012 spire.doc

有谁能说出如何使用spire.doc更改整个单词应用程序的字体大小?
如何选择整个文本范围并更改字体大小和样式?

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

在 Vb .net 中:

Dim document As New Document()
document.LoadFromFile("test.html", FileFormat.Html, XHTMLValidationType.None)
For Each section As Section In document.Sections
            For Each paragraph As Paragraph In section.Paragraphs
        For Each docObject As DocumentObject In paragraph.ChildObjects
            If docObject.DocumentObjectType = DocumentObjectType.TextRange Then
                Dim text As TextRange = TryCast(docObject, TextRange)
                text.CharacterFormat.FontName = "Calibri"
            End If
        Next docObject
    Next paragraph
Next section
document.SaveToFile("HtmlFileToPDF.pdf", FileFormat.PDF)