彩票走势图

如何使用Aspose Words将word 生成图片

转帖|使用教程|编辑:龚雪|2014-12-02 09:34:48.000|阅读 990 次

概述:利用Aspose.Words 把word 生成图片的代码示例。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

【年终大促 巅峰盛"慧" 】促销火热进行中 iPhone 6 Plus、 iPhone 6、iPad Air等你拿 点我查看

慧都年终巨献,Aspose系列产品黄金版+白金版享<8折>优惠!点我查看

FastReport VCL 5新版发布会,2014-12-9 15:00网络直播,免费参加 ,参加者买FastReport旗下所有产品<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);

 

您可能还对以下文章感兴趣:

狂欢继续!【年终大促 巅峰盛"慧" 】促销火热进行中 iPhone 6 Plus、 iPhone 6、iPad Air满就送,还不赶快买买买!


标签:Aspose.words

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP