文檔金喜正規買球>>Aspose中文文檔>>將 Word 文檔轉換為 PNG
將 Word 文檔轉換為 PNG
Aspose.Words是一種高級Word文檔處理API,用于執行各種文檔管理和操作任務。API支持生成,修改,轉換,呈現和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。
Aspose API支持流行文件格式處理,并允許將各類文檔導出或轉換為固定布局文件格式和最常用的圖像/多媒體格式。
要將 Word 文檔轉換為 PNG,只需調用Save方法并指定擴展名為“.PNG”的文件名即可。
從DOC轉換為PNG示例
// For complete examples and data files, please go to //github.com/aspose-words/Aspose.Words-for-.NET public static void ConvertDocumentToPNG() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); // Load a document Document doc = new Document(dataDir + "SampleImages.doc"); ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.Png); PageRange pageRange = new PageRange(0, doc.PageCount - 1); imageSaveOptions.PageSet = new PageSet(pageRange); imageSaveOptions.PageSavingCallback = new HandlePageSavingCallback(); doc.Save(dataDir + "output.png", imageSaveOptions); Console.WriteLine("\nDocument converted to PNG successfully."); } private class HandlePageSavingCallback : IPageSavingCallback { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_LoadingAndSaving(); public void PageSaving(PageSavingArgs args) { args.PageFileName = string.Format(dataDir + "Page_{0}.png", args.PageIndex); } }
點擊復制
代碼示例
運行代碼
如需下載產品Aspose.Words ,請點擊產品名進入下載頁面