Search code examples
c#.netscanningwia

C# WIA Automatic Document Feeder giving grey on sides


The problem I'm facing is that when I scan a A4 size page with a WIA based C# windows form application, the scanned image has grey on the sides. The scanner is automatic document feeder. Any help in this regard will be helpful?

The scanned image I am getting

private void SetupPageSize(Device wia, bool rotatePage, PageSize pageSize, int DPI, WIA.Item item)
    {

        //Setup Page Size Property
        foreach (WIA.Property itemProperty in item.Properties)
        {

            if (itemProperty.Name.Equals("Horizontal Resolution"))
            {
                ((IProperty)itemProperty).set_Value(DPI);
            }
            else if (itemProperty.Name.Equals("Vertical Resolution"))
            {
                ((IProperty)itemProperty).set_Value(DPI);
            }
            else if (itemProperty.Name.Equals("Horizontal Extent"))
            {

                double extent = DPI * pageSize.Height;

                if (rotatePage)
                {
                    extent = DPI * pageSize.Width;
                }
                //extent = 1250;
                //extent = 1230;


                ((IProperty)itemProperty).set_Value(extent);


            }
            else if (itemProperty.Name.Equals("Vertical Extent"))
            {
                double extent = DPI * pageSize.Width;

                if (rotatePage)
                {
                    extent = pageSize.Height * DPI;
                }
                Console.WriteLine("vertical extent:" + extent);
                //extent = extent + 500;
                //extent = 1750;

                ((IProperty)itemProperty).set_Value(extent);
            }

        }

    }

Solution

  • Paper sheet is not aligned in the feeder.