轉(zhuǎn)帖|使用教程|編輯:龔雪|2014-12-02 09:34:48.000|閱讀 1024 次
概述:利用Aspose.Words 把word 生成圖片的代碼示例。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
【年終大促 巔峰盛"慧" 】促銷火熱進(jìn)行中 iPhone 6 Plus、 iPhone 6、iPad Air等你拿 點(diǎn)我查看
慧都年終巨獻(xiàn),Aspose系列產(chǎn)品黃金版+白金版享<8折>優(yōu)惠!點(diǎn)我查看
FastReport VCL 5新版發(fā)布會(huì),2014-12-9 15:00網(wǎng)絡(luò)直播,免費(fèi)參加 ,參加者買FastReport旗下所有產(chǎn)品<6折>!
Aspose.Words.Document doc = new Aspose.Words.Document(HttpContext.Current.Server.MapPath(strFileName)); DocumentBuilder oWordApplic = new DocumentBuilder(doc); StringBuilder sb = new StringBuilder(); string headerStr = string.Format(@"<book pageheight='620' pagewidth='439' bgcolor='0xffffff' pagethickness='0.5' maxloaded='0' minscale='0.5' plugins='navigationbar, gallery, overlays, titles, anchors, swfaddress, links, keyboardnavigation, slideshow'> <chapter> <page stiff='true' anchor='cover'> <img aa='true' src='{0}/0.png' /> </page>", "lib"); string itemStr = @" <spreadpage> <img src='lib/{0}.png' /> </spreadpage>"; string tailStr = @" <page stiff='true'> <img src='lib/{0}.png' aa='true' /> </page> </chapter> </book>"; sb.Append(headerStr); float MyScale = 0.50f; float MyResolution = 150.0f; int count = doc.PageCount; for (int i = 0; i < count; i++) { if (i > 0 && i < count - 1) { sb.Append(string.Format(itemStr, i)); } PageInfo pageInfo = doc.GetPageInfo(i); Size pageSize = pageInfo.GetSizeInPixels(MyScale, MyResolution); using (Bitmap img = new Bitmap(pageSize.Width + 80, pageSize.Height)) { img.SetResolution(MyResolution, MyResolution); using (Graphics gr = Graphics.FromImage(img)) { gr.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; gr.FillRectangle(Brushes.White, 0, 0, pageSize.Width + 80, pageSize.Height); doc.RenderToScale(i, gr, 0, 0, MyScale); } img.Save(string.Format("{0}/{1}.png", Server.MapPath("lib"), i)); } } sb.Append(string.Format(tailStr, count - 1)); string content = sb.ToString(); Response.Write(content);
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)