扫描多页 [英] scanning multiple page

查看:59
本文介绍了扫描多页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我已经完成了扫描代码,当我们将单个文档放在扫描仪上时,它工作正常。如果我们放置多个文档,那么我们如何做它自动扫描所有?我的代码是



Hello All,

I have done code for scanning and it work fine when we put single document on scanner.If we put multiple document so how we do that it scan automatically all? My code is

// Scanner selected?
           var device = Devices.SelectedItem as Scanner;
           if (device == null)
           {
               MessageBox.Show("Please select a device.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
               return;
           }
           // Scan
           var images = device.Scan();
           //Save the image
           strFinalImagename = txtPolicyno.Text + "_" + ddlDept.SelectedItem + "." + ddlFormat.SelectedItem;

           string strImagename = "test.jpg";
           string path = System.Configuration.ConfigurationSettings.AppSettings["Path"] + strImagename;
           if (File.Exists(path))
           {
               File.Delete(path);
           }
           System.IO.Directory.CreateDirectory(System.Configuration.ConfigurationSettings.AppSettings["Path"]);

           images.SaveFile(path);

           string ImageText = txtPolicyno.Text + "_" + ddlDept.SelectedItem;

           //System.Drawing.Bitmap bitMapImage = new System.Drawing.Bitmap(path);
           //System.Drawing.Graphics graphicImage = System.Drawing.Graphics.FromImage(bitMapImage);
           //graphicImage.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
           //graphicImage.DrawArc(new System.Drawing.Pen(System.Drawing.Color.White, 3), 90, 235, 150, 50, 0, 360);
           //graphicImage.DrawString(ImageText, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.WindowText, new System.Drawing.Point(550, 20));

           ////bitMapImage.Save(@"D:\" + strFinalImagename, System.Drawing.Imaging.ImageFormat.Jpeg);
           //bitMapImage.Save(System.Configuration.ConfigurationSettings.AppSettings["Path"] + strFinalImagename, System.Drawing.Imaging.ImageFormat.Jpeg);
           //graphicImage.Dispose();
           //bitMapImage.Dispose();

           using (var src = new System.Drawing.Bitmap(path))
           using (var bmp = new System.Drawing.Bitmap(1000, 1000, System.Drawing.Imaging.PixelFormat.Format32bppPArgb))
           using (var gr = System.Drawing.Graphics.FromImage(bmp))
           {
               gr.Clear(System.Drawing.Color.Blue);
               gr.DrawImage(src, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height));
               gr.DrawString(ImageText, new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.WindowText, new System.Drawing.Point(550, 20));
               bmp.Save(System.Configuration.ConfigurationSettings.AppSettings["Path"] + strFinalImagename, System.Drawing.Imaging.ImageFormat.Png);
           }

推荐答案

这篇关于扫描多页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆