翻譯|使用教程|編輯:況魚杰|2021-03-11 14:40:40.973|閱讀 137 次
概述:TX Text Control .NET 15.0時(shí)已引入頁(yè)面渲染引擎,該引擎使您可以導(dǎo)出每個(gè)單獨(dú)頁(yè)面的圖元文件或位圖。 這使開發(fā)人員可以創(chuàng)建頁(yè)面的縮略圖或?qū)С鰣D像以在瀏覽器中查看它們。 此示例說明如何從文檔的所有頁(yè)面創(chuàng)建多頁(yè)TIFF圖像。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
TX Text Control .NET for Windows Forms 是一套功能豐富的文字處理控件,它以可重復(fù)使用控件的形式為開發(fā)人員提供了Word中常用的文字處理功能,對(duì)于需要強(qiáng)大且靈活的文檔處理能力的應(yīng)用程序而言,是理想的選擇。
點(diǎn)擊下載 TX Text Control .NET for Windows Forms X19試用版
TX Text Control .NET 15.0時(shí)已引入頁(yè)面渲染引擎,該引擎使您可以導(dǎo)出每個(gè)單獨(dú)頁(yè)面的圖元文件或位圖。 這使開發(fā)人員可以創(chuàng)建頁(yè)面的縮略圖或?qū)С鰣D像以在瀏覽器中查看它們。 此示例說明如何從文檔的所有頁(yè)面創(chuàng)建多頁(yè)TIFF圖像。
創(chuàng)建這些映像需要兩個(gè)重要步驟:
使用頁(yè)面渲染引擎創(chuàng)建TIFF圖像
將這些圖像合并為一個(gè)TIFF圖像
首先,需要遍歷TX Text Control的所有頁(yè)面以創(chuàng)建單獨(dú)的TIFF圖像:
ArrayList inputImages = new ArrayList(); foreach (Page page in textControl1.GetPages()) { MemoryStream image = new MemoryStream(); Bitmap bitmap = page.GetImage(100, TXTextControl.Page.PageContent.All); bitmap.Save(image, ImageFormat.Tiff); inputImages.Add(image); }
每個(gè)TIFF圖像都存儲(chǔ)在一個(gè)內(nèi)存流中,該內(nèi)存流被添加到ArrayList中,以便在組合它們時(shí)更容易處理。
在第二步驟中,將TIFF圖像合并為單個(gè)圖像。 因此,創(chuàng)建一個(gè)新圖像,以便使用SaveAdd方法將ArrayList中的所有其他圖像附加到新圖像的新框架中。
public static void CreateMultipageTIF(ArrayList InputImages, string Filename) { // set the image codec ImageCodecInfo info = null; foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders()) { if (ice.MimeType == "image/tiff") { info = ice; break; } } EncoderParameters ep = new EncoderParameters(2); bool firstPage = true; System.Drawing.Image img = null; // create an image instance from the 1st image for (int nLoopfile = 0; nLoopfile < InputImages.Count; nLoopfile++) { //get image from src file System.Drawing.Image img_src = System.Drawing.Image.FromStream((Stream)InputImages[nLoopfile]); Guid guid = img_src.FrameDimensionsList[0]; System.Drawing.Imaging.FrameDimension dimension = new System.Drawing.Imaging.FrameDimension(guid); //get the frames from src file for (int nLoopFrame = 0; nLoopFrame < img_src.GetFrameCount(dimension); nLoopFrame++) { img_src.SelectActiveFrame(dimension, nLoopFrame); ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionLZW)); // if first page, then create the initial image if (firstPage) { img = img_src; ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.MultiFrame)); img.Save(Filename, info, ep); firstPage = false; continue; } // add image to the next frame ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.FrameDimensionPage)); img.SaveAdd(img_src, ep); } } ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, Convert.ToInt32(EncoderValue.Flush)); img.SaveAdd(ep); }
文章推薦:
TX Text Control系列教程—Windows Forms:創(chuàng)建應(yīng)用程序
如果您對(duì)Text Control感興趣,可以咨詢購(gòu)買正版授權(quán)軟件。
關(guān)注慧聚IT微信公眾號(hào) ???,了解產(chǎn)品的最新動(dòng)態(tài)及最新資訊。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: