原創(chuàng)|其它|編輯:郝浩|2012-10-31 10:49:31.000|閱讀 7766 次
概述:頁面設(shè)置是存儲在Word文檔每個部分的一組格式化屬性。Aspose.Words只是提供直接通過Section.PageSetup property屬性訪問各個部分的頁面設(shè)置。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
如果你想要改變頁面設(shè)置(例如紙張大小、方向、利潤等)。當(dāng)您使用的是 Microsoft Word Automation,那么你可能會使用類似的代碼:
ActiveDocument.Range.PageSetup.PaperSize = wdPaperLetter
但是如果你使用的是Aspose.Words,你可以很容易地實(shí)現(xiàn)相同的功能。使用Aspose.Words唯一的區(qū)別是當(dāng)對于整個文檔應(yīng)用這些改變時,需要在文檔所有部分循環(huán)并修改每個部分的頁面設(shè)置。
頁面設(shè)置是存儲在Word文檔每個部分的一組格式化屬性。Microsoft Word Automation的ActiveDocument.Range.PageSetup是為文檔所有部分設(shè)置相同頁面的一個“捷徑”。Aspose.Words只是提供直接通過Section.PageSetup property屬性訪問各個部分的頁面設(shè)置。
C#
Document doc = new Document(MyDir + "Section.ModifyPageSetupInAllSections.doc"); // It is important to understand that a document can contain many sections and each // section has its own page setup. In this case we want to modify them all. foreach (Section section in doc) section.PageSetup.PaperSize = PaperSize.Letter; doc.Save(MyDir + "Section.ModifyPageSetupInAllSections Out.doc");
Visual Basic
Dim doc As New Document(MyDir & "Section.ModifyPageSetupInAllSections.doc") ' It is important to understand that a document can contain many sections and each ' section has its own page setup. In this case we want to modify them all. For Each section As Section In doc section.PageSetup.PaperSize = PaperSize.Letter Next section doc.Save(MyDir & "Section.ModifyPageSetupInAllSections Out.doc")
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)