cyanfish / naps2

Scan documents to PDF and more, as simply as possible.
https://www.naps2.com
Other
2.8k stars 325 forks source link

Incomplete Scanning Issue with Linux SANE #296

Open bay127prem opened 9 months ago

bay127prem commented 9 months ago

Describe the bug The sample code provided in HelloWorldSample.cs doesn't complete scanning the document when using Linux SANE. However, it works fine in Windows. The program exits with a 0 code before scanning the document, and the scanner stops in the middle of the process.

To Reproduce Steps to reproduce the behavior:

  1. Run the HelloWorldSample.cs on a Linux machine with SANE.
  2. Observe that the program exits with a 0 code before the scanning is complete.

Desktop:

Additional context This issue does not occur when running the same sample on Windows using WIA or TWAIN. NAPS2 App works fine in both OS.

bay127prem commented 8 months ago

Am I the only person who faces this issue ?

cyanfish commented 8 months ago

Try setting up logging:

scanningContext.Logger = new ConsoleLogger();

public class ConsoleLogger : ILogger
{
    public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
    {
        Console.WriteLine(state.ToString());
        if (exception != null) Console.WriteLine(exception.ToString());
    }
    public bool IsEnabled(LogLevel logLevel) => true;
    public IDisposable BeginScope<TState>(TState state) where TState : notnull => throw new NotImplementedException();
}
bay127prem commented 8 months ago

Option: 2 mode Scan mode Selects the scan mode (e.g., lineart, monochrome, or color). String None 7 SoftSelect, SoftDetect StringList Binary,Gray,Color Option: 3 depth Bit depth Number of bits per sample, typical values are 1 for "line-art" and 8 for multibit scans. Int None 4 SoftSelect, SoftDetect WordList 8,16 Option: 4 halftoning Halftoning Selects the halftone. String None 26 SoftSelect, SoftDetect, Inactive StringList None,Halftone A (Hard Tone),Halftone B (Soft Tone),Halftone C (Net Screen) Option: 5 dropout Dropout Selects the dropout. String None 6 SoftSelect, SoftDetect, Inactive, Advanced StringList None,Red,Green,Blue Option: 6 brightness-method Brightness Method Selects a method to change the brightness of the acquired image. String None 9 SoftSelect, SoftDetect, Advanced StringList iscan,gimp Option: 7 brightness Brightness Controls the brightness of the acquired image. Int None 4 SoftSelect, SoftDetect, Emulated Range -100-100/1 Option: 8 contrast Contrast Controls the contrast of the acquired image. Int None 4 SoftSelect, SoftDetect, Emulated Range -100-100/1 Option: 9 sharpness Sharpness Int None 4 SoftSelect, SoftDetect, Inactive Range -2-2/0 Option: 10 gamma-correction Gamma Correction Selects the gamma correction value from a list of pre-defined devices or the user defined table, which can be downloaded to the scanner String None 25 SoftSelect, SoftDetect StringList User defined (Gamma=1.0),User defined (Gamma=1.8) Option: 11 color-correction Color correction Sets the color correction table for the selected output device. String None 13 SoftSelect, SoftDetect, Inactive, Advanced StringList User defined Option: 12 resolution Scan resolution Sets the resolution of the scanned image. Int Dpi 4 SoftSelect, SoftDetect WordList 600 Option: 13 x-resolution X-resolution Sets the horizontal resolution of the scanned image. Int Dpi 4 SoftSelect, SoftDetect, Advanced WordList 150,225,300,600,900,1200 Option: 14 y-resolution Y-resolution Sets the vertical resolution of the scanned image. Int Dpi 4 SoftSelect, SoftDetect, Advanced WordList 150,225,300,600,900,1200,1800,2400 Option: 15 threshold Threshold Select minimum-brightness to get a white point Int None 4 SoftSelect, SoftDetect, Inactive Range 0-255/0 Option: 17 mirror Mirror image Mirror the image. Bool None 4 SoftSelect, SoftDetect, Inactive None Option: 18 speed Scan speed Determines the speed at which the scan proceeds. Bool None 4 SoftSelect, SoftDetect None Option: 19 auto-area-segmentation Auto area segmentation Bool None 4 SoftSelect, SoftDetect, Inactive None Option: 20 short-resolution Short resolution list Display short resolution list Bool None 4 SoftSelect, SoftDetect None Option: 21 zoom Zoom Defines the zoom factor the scanner will use Int None 4 SoftSelect, SoftDetect, Inactive Range 50-200/0 Option: 22 red-gamma-table Red intensity Gamma-correction table for the red band. Int None 1024 SoftSelect, SoftDetect Range 0-255/0 Option: 23 green-gamma-table Green intensity Gamma-correction table for the green band. Int None 1024 SoftSelect, SoftDetect Range 0-255/0 Option: 24 blue-gamma-table Blue intensity Gamma-correction table for the blue band. Int None 1024 SoftSelect, SoftDetect Range 0-255/0 Option: 25 wait-for-button Wait for Button After sending the scan command, wait until the button on the scanner is pressed to actually start the scan process. Bool None 4 SoftSelect, SoftDetect, Advanced None Option: 26 monitor-button Monitor Button Indicates whether a button on the scanner has been pressed. Bool None 4 SoftDetect, Advanced None Option: 27 polling-time Polling Time Time between queries when waiting for device state changes. Int Microsecond 4 SoftDetect, Advanced None Option: 28 needs-polling Needs Polling Indicates whether the scanner needs to poll. Bool None 4 SoftDetect, Advanced None Option: 30 cct-1 Red Controls red level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 31 cct-2 Shift green to red Adds to red based on green level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 32 cct-3 Shift blue to red Adds to red based on blue level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 33 cct-4 Shift red to green Adds to green based on red level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 34 cct-5 Green Controls green level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 35 cct-6 Shift blue to green Adds to green based on blue level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 36 cct-7 Shift red to blue Adds to blue based on red level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 37 cct-8 Shift green to blue Adds to blue based on green level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 38 cct-9 Blue Control blue level Fixed None 4 SoftSelect, SoftDetect, Emulated, Advanced Range -2-2/0 Option: 40 preview Preview Request a preview-quality scan. Bool None 4 SoftSelect, SoftDetect None Option: 41 preview-speed Speed Bool None 4 SoftSelect, SoftDetect None Option: 43 scan-area Scan area Select an area to scan based on well-known media sizes. String None 13 SoftSelect, SoftDetect StringList Maximum,A4,A5 Landscape,A5 Portrait,B5,Letter,Executive,CD Option: 44 tl-x Top-left x Top-left x position of scan area. Fixed Mm 4 SoftSelect, SoftDetect Range 0-215.90000762951095/0 Option: 45 tl-y Top-left y Top-left y position of scan area. Fixed Mm 4 SoftSelect, SoftDetect Range 0-297.1799954222934/0 Option: 46 br-x Bottom-right x Bottom-right x position of scan area. Fixed Mm 4 SoftSelect, SoftDetect Range 0-215.90000762951095/0 Option: 47 br-y Bottom-right y Bottom-right y position of scan area. Fixed Mm 4 SoftSelect, SoftDetect Range 0-297.1799954222934/0 Option: 48 quick-format Quick format Select an area to scan based on well-known media sizes. (DEPRECATED) String None 13 SoftSelect, SoftDetect StringList Maximum,A4,A5 Landscape,A5 Portrait,B5,Letter,Executive,CD Option: 50 source Scan source Selects the scan source (such as a document-feeder). String None 26 SoftSelect, SoftDetect StringList Flatbed,Automatic Document Feeder Option: 51 auto-eject Auto eject Eject document after scanning Bool None 4 SoftSelect, SoftDetect None Option: 52 film-type Film type String None 14 SoftSelect, SoftDetect, Inactive StringList Positive Film,Negative Film Option: 53 focus-position Focus Position Sets the focus position to either the glass or 2.5mm above the glass String None 24 SoftSelect, SoftDetect, Inactive, Advanced StringList Focus on glass,Focus 2.5mm above glass Option: 54 bay Bay Select bay to scan String None 4 SoftSelect, SoftDetect, Inactive StringList 1 , 2 , 3 , 4 , 5 , 6 Option: 55 eject Eject Eject the sheet in the ADF Button None 4 SoftSelect, SoftDetect None Option: 56 adf-mode ADF Mode Selects the ADF mode (simplex/duplex) String None 8 SoftSelect, SoftDetect, Inactive StringList Simplex,Duplex Option: 57 detect-doc-size Auto-detect document size Activates document size auto-detection. The scan area will be set to match the detected document size. Bool None 4 SoftSelect, SoftDetect, Inactive, Advanced None Option: 58 scan-area-is-valid Scan Area Is Valid Indicates whether the current scan area settings are valid. Bool None 4 SoftDetect, Advanced None Option: 59 adf-auto-scan ADF Auto Scan Skips per sheet device setup for faster throughput. Bool None 4 SoftSelect, SoftDetect, Inactive, Advanced None Option: 60 double-feed-detection-sensitivity Double Feed Detection Sensitivity Sets the sensitivity with which multi-sheet page feeds are detected and reported as errors. String None 5 SoftSelect, SoftDetect, Inactive, Advanced StringList None,Low,High Option: 61 ext-sane-status Extended SANE Status Ugly kludge to provide additional status message strings to a frontend. Int None 4 SoftDetect, Advanced Range 0-2/0 Option: 62 adf-duplex-direction-matches ADF Duplex Direction Matches Indicates whether the device's ADF duplex mode, if available, scans in the same direction for the front and back. Bool None 4 SoftDetect, Inactive, Advanced None Option: 63 deskew Deskew Rotate image so it appears upright. Bool None 4 SoftSelect, SoftDetect, Emulated, Inactive, Advanced None Option: 64 autocrop Trim image to paper size Determines empty margins in the scanned image and removes them. This normally reduces the image to the size of the original document but may remove more. Bool None 4 SoftSelect, SoftDetect, Emulated, Inactive, Advanced None Option: 65 calibrate Calibrate Performs color matching to make sure that the document's color tones are scanned correctly. Button None 4 SoftSelect, SoftDetect, Inactive, Advanced None Option: 66 clean Clean Cleans the scanners reading section. Button None 4 SoftSelect, SoftDetect, Inactive, Advanced None Maybe setting source Setting source to Automatic Document Feeder Maybe setting mode Setting mode to Color Correcting DPI from 100 to 600 Maybe setting resolution Setting resolution to 600 Maybe setting tl-x Setting tl-x to 0 Maybe setting tl-y Setting tl-y to 0 Maybe setting br-x Setting br-x to 210 Maybe setting br-y Setting br-y to 297