原創|其它|編輯:郝浩|2012-09-20 11:50:15.000|閱讀 5304 次
概述:大家都知道,在設置了頁碼的文檔中插入分節符,新一節默認的起始頁碼是繼承上一節的頁碼屬性的。例如第一節最后一頁為第2頁,插入分節符后,新一頁的頁碼為第3頁。如果希望新節的頁碼從1開始重新編號,在Microsoft Word 中,我們可以調出“頁眉和頁腳”選項卡,選擇“頁碼”進行相應的設置。 那么,Aspose.Words for .NET又是如何在分節后對頁碼進行重新編號的呢?
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
大家都知道,在設置了頁碼的文檔中插入分節符,新一節默認的起始頁碼是繼承上一節的頁碼屬性的。例如第一節最后一頁為第2頁,插入分節符后,新一頁的頁碼為第3頁。如果希望新節的頁碼從1開始重新編號,在Microsoft Word 中,我們可以調出“頁眉和頁腳”選項卡,選擇“頁碼”進行相應的設置。
那么,Aspose.Words .NET又是如何在分節后對頁碼進行重新編號的呢?讓我們通過一個具體的事例來進行深入的了解:
事例代碼如下:
C#
Document dstDoc = new Document(gDataDir + "TestFile.Destination.doc");
Document srcDoc = new Document(gDataDir + "TestFile.Source.doc");
// Set the appended document to appear on the next page.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
// Restart the page numbering for the document to be appended.
srcDoc.FirstSection.PageSetup.RestartPageNumbering = true;
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
dstDoc.Save(gDataDir + "TestFile.RestartPageNumbering Out.doc");
Visual Basic
Dim dstDoc As New Document(gDataDir & "TestFile.Destination.doc")
Dim srcDoc As New Document(gDataDir & "TestFile.Source.doc")
' Set the appended document to appear on the next page.
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage
' Restart the page numbering for the document to be appended.
srcDoc.FirstSection.PageSetup.RestartPageNumbering = True
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting)
dstDoc.Save(gDataDir & "TestFile.RestartPageNumbering Out.doc")
運行代碼后的效果圖如下:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網