利用Aspose.Words 把word 生成图片
2014-07-02 08:50
267 查看
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);
相关文章推荐
- 利用poi生成word(含表格 图片)
- 利用freemarker 在模板里面写入动态数据,动态表格,图片插入并生成word文档
- 利用freemarker生成word(带图片)
- 利用freemarker 在模板里面写入动态数据,动态表格,图片插入并生成word文档
- 利用word模板生成word或pdf文件并输出
- asp.net下用Aspose.Words for .NET动态生成word文档中的图片或水印的方法(转)
- 在asp.net生成的word文档中插入图片
- [导入]利用PIL生成水印图片或文字
- 利用ASPUPLOAD,ASPJPEG实现图片上传自动生成缩略图及加上水印
- 利用iText生成word文档例子参考
- 利用PHP为大图片生成缩略图代码实现
- 在asp.net生成的word文档中插入图片(转)
- 利用Java Apache POI 生成Word文档
- 利用IText生成word、pdf文档
- Itext中 根据html生成Word文件,包含图片
- jetway_loves_programming之c#初学——如何利用asp.net生成word
- 在asp.net生成的word文档中插入图片
- 向Word中插入图片,C#编写的生成缩略图程序
- 利用XML生成Word
- Android平台利用ZXING生成二维码图片