翻譯|使用教程|編輯:李顯亮|2020-06-10 11:45:24.300|閱讀 689 次
概述:Aspose.Words for .NET是一種高級Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務(wù)。本文將介紹如何使用Ole對象和在線視頻相關(guān)知識。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Aspose.Words for .NET是一種高級Word文檔處理API,用于執(zhí)行各種文檔管理和操作任務(wù)。API支持生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印文檔,而無需在跨平臺應(yīng)用程序中直接使用Microsoft Word。此外,API支持所有流行的Word處理文件格式,并允許將Word文檔導(dǎo)出或轉(zhuǎn)換為固定布局文件格式和最常用的圖像/多媒體格式。
>>Aspose.Words for .NET已經(jīng)更新至v20.6,Font.EmphasisMark向公眾公開,引入了MarkdownSaveOptions類,PDF版本1.5標(biāo)記為過時,點擊下載體驗
如果要Ole Object調(diào)用 DocumentBuilder.InsertOleObject。將ProgId與其他參數(shù)一起顯式傳遞給此方法。下例顯示了如何將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);
插入對象時設(shè)置文件名和擴(kuò)展名
如果OLE處理程序未知,則OLE包是用于存儲嵌入式對象的舊式“未記錄”方式。Windows 3.1、95和98等早期Windows版本具有Packager.exe應(yīng)用程序,該應(yīng)用程序可用于將任何類型的數(shù)據(jù)嵌入到文檔中。現(xiàn)在,此應(yīng)用程序已從Windows排除在外,但是如果OLE處理程序丟失或未知,MS Word和其他應(yīng)用程序仍將其用于嵌入數(shù)據(jù)。OlePackage類允許訪問OLE包屬性。下面的示例演示如何設(shè)置OLE包的文件名,擴(kuò)展名和顯示名。
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對象原始數(shù)據(jù)的訪問
下面的代碼示例演示如何使用OleFormat.GetRawData()方法獲取OLE對象原始數(shù)據(jù) 。
// 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。您可以通過調(diào)用DocumentBuilder.InsertOnlineVideo 方法將在線視頻插入當(dāng)前位置的 文檔中。DocumentBuilder類中引入了此方法的四個重載。第一個使用最受歡迎的視頻資源,并將視頻的URL作為參數(shù)。
//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代碼作為參數(shù):
//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);
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn