文檔首頁>>Aspose中文文檔>>打印文件
打印文件
Aspose.Words是一種高級Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務(wù)。API支持生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印文檔,而無需在跨平臺應(yīng)用程序中直接使用Microsoft Word。
Aspose API支持流行文件格式處理,并允許將各類文檔導(dǎo)出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。
VSTO
調(diào)用要打印的Document對象的PrintOut方法。以下代碼示例打印活動的整個文檔或任何當(dāng)前活動頁面:
this.Application.ActiveDocument.PrintOut(true, false, Word.WdPrintOutRange.wdPrintAllDocument, Item: Word.WdPrintOutItem.wdPrintDocumentContent, Copies: "1", Pages: "", PageType: Word.WdPrintOutPages.wdPrintAllPages, PrintToFile: false, Collate: true, ManualDuplexPrint: false); object copies = "1"; object pages = "1"; object range = Word.WdPrintOutRange.wdPrintCurrentPage; object items = Word.WdPrintOutItem.wdPrintDocumentContent; object pageType = Word.WdPrintOutPages.wdPrintAllPages; object oTrue = true; object oFalse = false; Word.Document document = this.Application.ActiveDocument; document.PrintOut( ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing, ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
點擊復(fù)制
下面是打印單個文檔或特定文檔的任何頁面的代碼示例:
string FileName = "YourFileName.docx"; Document doc = new Document(FileName); doc.Print(); PrinterSettings PrinterSettings = new PrinterSettings(); PrinterSettings.MinimumPage = 1; PrinterSettings.MaximumPage = doc.PageCount; PrinterSettings.FromPage = 1; PrinterSettings.ToPage = doc.PageCount; doc.Print(PrinterSettings);
點擊復(fù)制
下載示例代碼