How to change background color grey to white while scanning smaller documents

Issue #121 resolved
Emre Çakır created an issue

Hello ,I want to scan all documents into A4 paper size.But when I try to scan a smaller document,Empty areas are all grey .I’m merging documents into a pdf document by using itextsharp.And I want all documents are A4paper size.

Is there any way to change background color to white ?( by the way ICapAutomaticBorderDetection is removing all grey areas ,but I’m wanting to keep empty areas as white ).

thanks ,have a nice day.

Comments (3)

  1. Eugene Wang repo owner

    Unless the driver supports changing the edge background color (unlikely), you’ll have to modify the image after scanning. I can think of 2 ways of doing that.

    • Detect border color pixels and put white color there
    • Use a pre-generated white A4 image and copy the small ICapAutomaticBorderDetection’d image on top of it.

    You can try to do either in code or use an external tool like ImageMagick (I guess with trim and composite commands, though I’ve never done this myself).

  2. Emre Çakır reporter

    Thanks for your advices Eugene.I tried ICapAutomaticBorderDetection and pre-generated white A4 image.Its a good solution ,but sometimes it’s not working good.Border detection sometimes can not cleaning good.

    Perfect solution for me is to change color to white from gray.I think there is no property to use white color as default color in empty areas on paper in ntwain library.

    Here is an example ,I tried to scan smaller paper than A4 ,.And if I use border detection ,its working but not always. It’s sometimes not removing all gray areas on paper.

  3. Log in to comment