翻譯|使用教程|編輯:李顯亮|2020-06-10 11:45:24.300|閱讀 682 次
概述:Aspose.Words for .NET是一種高級Word文檔處理API,用于執行各種文檔管理和操作任務。本文將介紹如何使用Ole對象和在線視頻相關知識。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.Words for .NET是一種高級Word文檔處理API,用于執行各種文檔管理和操作任務。API支持生成,修改,轉換,呈現和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。此外,API支持所有流行的Word處理文件格式,并允許將Word文檔導出或轉換為固定布局文件格式和最常用的圖像/多媒體格式。
>>Aspose.Words for .NET已經更新至v20.6,Font.EmphasisMark向公眾公開,引入了MarkdownSaveOptions類,PDF版本1.5標記為過時,點擊下載體驗
如果要Ole Object調用 DocumentBuilder.InsertOleObject。將ProgId與其他參數一起顯式傳遞給此方法。下例顯示了如何將Ole Object插入文檔。
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertOleObject("http://www.aspose.com", "htmlfile", true, true, null); dataDir = dataDir + "DocumentBuilderInsertOleObject_out.doc"; doc.Save(dataDir);
插入對象時設置文件名和擴展名
如果OLE處理程序未知,則OLE包是用于存儲嵌入式對象的舊式“未記錄”方式。Windows 3.1、95和98等早期Windows版本具有Packager.exe應用程序,該應用程序可用于將任何類型的數據嵌入到文檔中。現在,此應用程序已從Windows排除在外,但是如果OLE處理程序丟失或未知,MS Word和其他應用程序仍將其用于嵌入數據。OlePackage類允許訪問OLE包屬性。下面的示例演示如何設置OLE包的文件名,擴展名和顯示名。
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); byte[] bs = File.ReadAllBytes(dataDir + @"input.zip"); using (Stream stream = new MemoryStream(bs)) { Shape shape = builder.InsertOleObject(stream, "Package", true, null); OlePackage olePackage = shape.OleFormat.OlePackage; olePackage.FileName = "filename.zip"; olePackage.DisplayName = "displayname.zip"; dataDir = dataDir + "DocumentBuilderInsertOleObjectOlePackage_out.doc"; doc.Save(dataDir); }
獲取對OLE對象原始數據的訪問
下面的代碼示例演示如何使用OleFormat.GetRawData()方法獲取OLE對象原始數據 。
// Load document with OLE object. Document doc = new Document(dataDir + "DocumentBuilderInsertTextInputFormField_out.doc"); Shape oleShape = (Shape)doc.GetChild(NodeType.Shape, 0, true); byte[] oleRawData = oleShape.OleFormat.GetRawData();
可以從“插入”選項卡>“在線視頻”將在線視頻插入MS Word。您可以通過調用DocumentBuilder.InsertOnlineVideo 方法將在線視頻插入當前位置的 文檔中。DocumentBuilder類中引入了此方法的四個重載。第一個使用最受歡迎的視頻資源,并將視頻的URL作為參數。
//The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithOnlineVideo(); Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Pass direct url from youtu.be. string url = "http://youtu.be/t_1LYZ102RA"; double width = 360; double height = 270; Shape shape = builder.InsertOnlineVideo(url, width, height); dataDir = dataDir + "Insert.OnlineVideo_out_.docx"; doc.Save(dataDir);
第二次重載可與所有其他視頻資源一起使用,并將嵌入的HTML代碼作為參數:
//The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithOnlineVideo(); Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Shape width/height. double width = 360; double height = 270; // Poster frame image. byte[] imageBytes = File.ReadAllBytes("TestImage.jpg"); // Visible url string vimeoVideoUrl = @"http://vimeo.com/52477838"; // Embed Html code. string vimeoEmbedCode = ""; builder.InsertOnlineVideo(vimeoVideoUrl, vimeoEmbedCode, imageBytes, width, height); dataDir = dataDir + "Insert.OnlineVideo_out_.docx"; doc.Save(dataDir);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn