当前位置: 首页 > news >正文

个人主题网站设计论文百度域名提交收录网址

个人主题网站设计论文,百度域名提交收录网址,互联网营销师培训课程,导购网站自己做电商说明 有时需要把PDF的每一页另存为图片。用Devexpress可以很方便的完成这个功能。 窗体上放置一个PdfViewer。 然后循环每一页 for (int i 1; i < pdfViewer1.PageCount; i) 调用 chg_pdf_to_bmp函数获得图片并保存 chg_pdf_to_bmp中调用了PdfViewer的CreateBitmap函数…

说明

有时需要把PDF的每一页另存为图片。用Devexpress可以很方便的完成这个功能。

窗体上放置一个PdfViewer。

然后循环每一页 for (int i = 1; i <= pdfViewer1.PageCount; i++)

调用 chg_pdf_to_bmp函数获得图片并保存

chg_pdf_to_bmp中调用了PdfViewer的CreateBitmap函数

全部代码

        private string pdf_fn = "";
        private void button1_Click(object sender, EventArgs e)
        {
            pdf_fn = textBox1.Text.Trim();
            if (! System.IO.File.Exists(pdf_fn))
                return;
            button1.Enabled = false;
            string dir = System.IO.Path.GetDirectoryName(pdf_fn) + @"\" + System.IO.Path.GetFileNameWithoutExtension(pdf_fn) + ".files";
            if (!System.IO.Directory.Exists(dir))
                System.IO.Directory.CreateDirectory(dir);
            pdfViewer1.LoadDocument(pdf_fn);
            progressBar1.Value = 0;
            progressBar1.Maximum = pdfViewer1.PageCount;
            Application.DoEvents();
            for (int i = 1; i <= pdfViewer1.PageCount; i++)
            {
                Bitmap bmp = chg_pdf_to_bmp(pdfViewer1,i);

                bmp.Save(dir+@"\"+i.ToString()+".jpg", ImageFormat.Jpeg ); 

                bmp.Dispose();
                progressBar1.Value = progressBar1.Value +1;
                Application.DoEvents();
            }
            MessageBox.Show("保存在"+ dir+"下");
            button1.Enabled = true;

        }

        private string pdf_fn = "";private void button1_Click(object sender, EventArgs e){pdf_fn = textBox1.Text.Trim();if (! System.IO.File.Exists(pdf_fn))return;button1.Enabled = false;string dir = System.IO.Path.GetDirectoryName(pdf_fn) + @"\" + System.IO.Path.GetFileNameWithoutExtension(pdf_fn) + ".files";if (!System.IO.Directory.Exists(dir))System.IO.Directory.CreateDirectory(dir);pdfViewer1.LoadDocument(pdf_fn);progressBar1.Value = 0;progressBar1.Maximum = pdfViewer1.PageCount;Application.DoEvents();for (int i = 1; i <= pdfViewer1.PageCount; i++){Bitmap bmp = chg_pdf_to_bmp(pdfViewer1,i);bmp.Save(dir+@"\"+i.ToString()+".jpg", ImageFormat.Jpeg ); bmp.Dispose();progressBar1.Value = progressBar1.Value +1;Application.DoEvents();}MessageBox.Show("保存在"+ dir+"下");button1.Enabled = true;}

        public Bitmap chg_pdf_to_bmp(DevExpress.XtraPdfViewer.PdfViewer VW_PDF, int i_page_no, int max_w = 210 * 4 * 3)
        {
            DevExpress.Pdf.PdfDocument _pdf_document = null;
            VW_PDF.CurrentPageNumber = i_page_no;
            VW_PDF.Refresh();
            System.Reflection.PropertyInfo fiDocument = VW_PDF.GetType().GetProperty("Document", BindingFlags.Instance | BindingFlags.NonPublic);
            _pdf_document = fiDocument.GetValue(VW_PDF, null) as DevExpress.Pdf.PdfDocument;

            PdfPage pdfpage = _pdf_document.Pages[i_page_no - 1];
            SizeF page_sf = VW_PDF.GetPageSize(i_page_no);
            int pw = (int)(page_sf.Width / pdfpage.UserUnit * 500);
            int ph = (int)(page_sf.Height / pdfpage.UserUnit * 500);
            int bmp_w = pw;                                            //pw * 3 / 2;
            int bmp_h = ph;                                            //ph * 3 / 2; 
            if (bmp_w > max_w)
                bmp_w = max_w;
            Bitmap bmp = VW_PDF.CreateBitmap(i_page_no, bmp_w);
            return bmp;
        }

        public Bitmap chg_pdf_to_bmp(DevExpress.XtraPdfViewer.PdfViewer VW_PDF, int i_page_no, int max_w = 210 * 4 * 3){DevExpress.Pdf.PdfDocument _pdf_document = null;VW_PDF.CurrentPageNumber = i_page_no;VW_PDF.Refresh();System.Reflection.PropertyInfo fiDocument = VW_PDF.GetType().GetProperty("Document", BindingFlags.Instance | BindingFlags.NonPublic);_pdf_document = fiDocument.GetValue(VW_PDF, null) as DevExpress.Pdf.PdfDocument;PdfPage pdfpage = _pdf_document.Pages[i_page_no - 1];SizeF page_sf = VW_PDF.GetPageSize(i_page_no);int pw = (int)(page_sf.Width / pdfpage.UserUnit * 500);int ph = (int)(page_sf.Height / pdfpage.UserUnit * 500);int bmp_w = pw;                                            //pw * 3 / 2;int bmp_h = ph;                                            //ph * 3 / 2; if (bmp_w > max_w)bmp_w = max_w;Bitmap bmp = VW_PDF.CreateBitmap(i_page_no, bmp_w);return bmp;}

http://www.tj-hxxt.cn/news/88489.html

相关文章:

  • 东莞企业网站设计百度一级代理商
  • 德国站有哪些做站外秒杀的网站站长素材官网免费
  • 如何做阿里巴巴国际网站正规seo多少钱
  • 工程公司排名seo百度发包工具
  • 网站程序调试模式怎么做某网站seo诊断分析和优化方案
  • 网站后台管理系统源码东莞seo建站排名
  • 响应式购物网站关键词查询优化
  • 网站服务端做处理跨域深圳最新疫情
  • 可以做软件的网站辅导班
  • wordpress自定义文章流程常州seo招聘
  • 做社区网站免费seo网站的工具
  • 室内设计效果图360全景图哈尔滨seo关键词
  • 漳州正规网站建设百度网盘官网入口
  • 哪个网站可以发宝贝链接做宣传杭州网站建设书生商友
  • 英文都不懂 学网站建设维护难吗华联股份股票
  • 自己开个网站网络营销推广难做吗
  • 长春工程公司招聘百度seo怎么做网站内容优化
  • 温州手机网站制作多少钱头条新闻
  • 惠安网站建设百度关键词优化和百度推广
  • 做网站的被拘留了深圳百度推广公司
  • 深圳福田区住建局官网seo技术教程
  • 新闻网站数据库建设八种营销模式
  • 创意网站建设电脑优化软件推荐
  • 网站设计需求说明书谷歌网址
  • 上海最好网站建设公司媒体发布公司
  • 网站建设国内外研究现状模板百度一下你就知道啦
  • wordpress外链包装路由优化大师官网
  • 哪里有做空包网站的温州seo
  • 口碑好的无锡网站建设做引流推广的平台600
  • 重庆做石材的网站企业推广的网站