Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canon DR-M140 pages get cut off when using SDK #478

Open
cityvoice opened this issue Oct 29, 2024 · 4 comments
Open

Canon DR-M140 pages get cut off when using SDK #478

cityvoice opened this issue Oct 29, 2024 · 4 comments

Comments

@cityvoice
Copy link

cityvoice commented Oct 29, 2024

I'm having a problem with my canon scanners in using SDK. When I scan an A4 paper it cuts of the first ( or last ) 1cm of the page.
the same problem like:
https://gitlab.com/sane-project/backends/-/issues/476#note_1735474004

I'm using SDK to develop an electron app, I using browser to send a scan job to scanner with options:
{
InputSource: 'ADF',
Duplex: true,
Resolution: 300,
ScanRegion: 'A4',
}

it cut off the bottom 1cm of the page. But it works fine when using NAPS2 gui or command line tool NAPS2.Console.exe

so how to resolve this bug, thanks!

@cyanfish
Copy link
Owner

Try "ScanRegions" instead of "ScanRegion".

@cityvoice
Copy link
Author

cityvoice commented Oct 29, 2024

ScanRegions

hi@cyanfish, very thanks for your replyment, I have tried "ScanRegions" instead of "ScanRegion", but the scan server throws 400 error.

the post data is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><scan:ScanSettings xmlns:scan="http://schemas.hp.com/imaging/escl/2011/05/03" xmlns:pwg="http://www.pwg.org/schemas/2010/12/sm" xmlns:dest="http://schemas.hp.com/imaging/httpdestination/2011/10/13"><pwg:InputSource>Feeder</pwg:InputSource><scan:Duplex>false</scan:Duplex><pwg:ScanRegions><pwg:ScanRegion pwg:MustHonor><pwg:Height>3507</pwg:Height><pwg:Width>2481</pwg:Width><pwg:XOffset>0</pwg:XOffset><pwg:YOffset>0</pwg:YOffset></pwg:ScanRegion></pwg:ScanRegions><pwg:Version>2</pwg:Version><scan:XResolution>300</scan:XResolution><scan:YResolution>300</scan:YResolution></scan:ScanSettings>

maxWidth and maxHeight:

{
  'scan:MinWidth': 1,
  'scan:MaxWidth': 5000,
  'scan:MinHeight': 1,
  'scan:MaxHeight': 5000,
  'scan:MaxScanRegions': 1,
  'scan:SettingProfiles': {
    'scan:SettingProfile': {
      'scan:ColorModes': [Object],
      'scan:DocumentFormats': [Object],
      'scan:SupportedResolutions': [Object]
    }
  }
}

scanner capablility:

scanner capabilities {
  capabilities: {
    '?xml': { _version: '1.0', _encoding: 'UTF-8' },
    'scan:ScannerCapabilities': {
      'pwg:Version': 2.6,
      'pwg:MakeAndModel': 'CANON DR-M140 USB',
      'pwg:SerialNumber': '',
      'scan:Manufacturer': '',
      'scan:UUID': '1ea13cde-d627-aed1-e107-063377d2e470',
      'scan:AdminURI': '',
      'scan:IconURI': '',
      'scan:Naps2Extensions': 'Progress;ErrorDetails;ShortTimeout',
      'scan:Platen': [Object],
      'scan:Adf': [Object],
      'scan:CompressionFactorSupport': [Object],
      '_xmlns:scan': 'http://schemas.hp.com/imaging/escl/2011/05/03',
      '_xmlns:pwg': 'http://www.pwg.org/schemas/2010/12/sm'
    }
  },
  scansetting: {
    adf: {
      Simplex: [Array],
      Duplex: [Array],
      AdfOptions: [],
      FeederCapacity: undefined
    },
    platen: [ [Object], [Object], [Object], [Object] ]
  },
  BrightnessSupport: null
}

this is the full error code:

scanner err AxiosError: Request failed with status code 400
at settle (file:///D:/projects/lianxing/pcclient/node_modules/.pnpm/[email protected]/node_modules/axios/lib/core/settle.js:19:12)
at IncomingMessage.handleStreamEnd (file:///D:/projects/lianxing/pcclient/node_modules/.pnpm/[email protected]/node_modules/axios/lib/adapters/http.js:599:11)
at IncomingMessage.emit (node:events:526:35)
at endReadableNT (node:internal/streams/readable:1408:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (file:///D:/projects/lianxing/pcclient/node_modules/.pnpm/[email protected]/node_modules/axios/lib/core/Axios.js:45:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Scanner.ScanJobs (file:///D:/projects/lianxing/pcclient/dist-electron/main/workers/scan.js:366:15)
at async startScan (file:///D:/projects/lianxing/pcclient/dist-electron/main/workers/scan.js:429:20) {
code: 'ERR_BAD_REQUEST',
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http', 'fetch' ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: [class Blob] },
validateStatus: [Function: validateStatus],
headers: Object [AxiosHeaders] {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'axios/1.7.7',
'Content-Length': '648',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
method: 'post',
data: '<scan:ScanSettings xmlns:scan="http://schemas.hp.com/imaging/escl/2011/05/03" xmlns:pwg="http://www.pwg.org/schemas/2010/12/sm" xmlns:dest="http://schemas.hp.com/imaging/httpdestination/2011/10/13">pwg:InputSourceFeeder</pwg:InputSource>scan:Duplexfalse</scan:Duplex>pwg:ScanRegions<pwg:ScanRegion pwg:MustHonor>pwg:Height3507</pwg:Height>pwg:Width2481</pwg:Width>pwg:XOffset0</pwg:XOffset>pwg:YOffset0</pwg:YOffset></pwg:ScanRegion></pwg:ScanRegions>pwg:Version2</pwg:Version>scan:XResolution300</scan:XResolution>scan:YResolution300</scan:YResolution></scan:ScanSettings>',
url: 'http://127.0.0.1:9881/eSCL/ScanJobs'
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
finish: [Function: requestOnFinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: '648',
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: Socket {
connecting: false,
_hadError: false,
_parent: null,
_host: null,
_closeAfterHandlingError: false,
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: null,
_server: null,
timeout: 5000,
parser: null,
_httpMessage: [Circular *1],
[Symbol(async_id_symbol)]: 299,
[Symbol(kHandle)]: [TCP],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: Timeout {
_idleTimeout: 5000,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 290,
_onTimeout: [Function: bound ],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(refed)]: false,
[Symbol(kHasPrimitive)]: false,
[Symbol(asyncId)]: 298,
[Symbol(triggerId)]: 0
},
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: true,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 60,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0
},
_header: 'POST /eSCL/ScanJobs HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/x-www-form-urlencoded\r\n' +
'User-Agent: axios/1.7.7\r\n' +
'Content-Length: 648\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'Host: 127.0.0.1:9881\r\n' +
'Connection: keep-alive\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype],
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/eSCL/ScanJobs',
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
socket: [Socket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
joinDuplicateHeaders: undefined,
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 400,
statusMessage: 'Bad Request',
client: [Socket],
_consuming: false,
_dumped: false,
req: [Circular *1],
responseUrl: 'http://127.0.0.1:9881/eSCL/ScanJobs',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 20,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0
},
aborted: false,
timeoutCb: [Function: emitRequestTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: '127.0.0.1',
protocol: 'http:',
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 648,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular 1],
_currentUrl: 'http://127.0.0.1:9881/eSCL/ScanJobs',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [Array],
'content-type': [Array],
'user-agent': [Array],
'content-length': [Array],
'accept-encoding': [Array],
host: [Array]
},
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null
},
response: {
status: 400,
statusText: 'Bad Request',
headers: Object [AxiosHeaders] {
expires: 'Sat, 26 Jul 1997 05:00:00 GMT',
'last-modified': 'Tue, 29 Oct 2024 02:13:16 GMT',
'cache-control': 'no-store, no-cache, must-revalidate',
pragma: 'no-cache',
'access-control-allow-origin': '
',
'content-type': 'text/html; charset=utf-8',
server: 'EmbedIO/3.5.2',
date: 'Tue, 29 Oct 2024 02:13:16 GMT',
'content-length': '0',
connection: 'close'
},
config: {
transitional: [Object],
adapter: [Array],
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: [Object],
validateStatus: [Function: validateStatus],
headers: [Object [AxiosHeaders]],
method: 'post',
data: '<scan:ScanSettings xmlns:scan="http://schemas.hp.com/imaging/escl/2011/05/03" xmlns:pwg="http://www.pwg.org/schemas/2010/12/sm" xmlns:dest="http://schemas.hp.com/imaging/httpdestination/2011/10/13">pwg:InputSourceFeeder</pwg:InputSource>scan:Duplexfalse</scan:Duplex>pwg:ScanRegions<pwg:ScanRegion pwg:MustHonor>pwg:Height3507</pwg:Height>pwg:Width2481</pwg:Width>pwg:XOffset0</pwg:XOffset>pwg:YOffset0</pwg:YOffset></pwg:ScanRegion></pwg:ScanRegions>pwg:Version2</pwg:Version>scan:XResolution300</scan:XResolution>scan:YResolution300</scan:YResolution></scan:ScanSettings>',
url: 'http://127.0.0.1:9881/eSCL/ScanJobs'
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: false,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: '648',
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [Socket],
_header: 'POST /eSCL/ScanJobs HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/x-www-form-urlencoded\r\n' +
'User-Agent: axios/1.7.7\r\n' +
'Content-Length: 648\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'Host: 127.0.0.1:9881\r\n' +
'Connection: keep-alive\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/eSCL/ScanJobs',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: [Function: emitRequestTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: '127.0.0.1',
protocol: 'http:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null
},
data: ''
},
status: 400
}

so how should i do? thanks

@cyanfish
Copy link
Owner

Looks like a bug in the ESCL client library as it's generating invalid XML, I'm assuming you're using the code from the naps2-webscan sample? If so you can try commenting out lines 25 and 33 here (the lines with "MustHonor").

@cityvoice
Copy link
Author

@cyanfish, thanks again, you are right,xml is invalid, change region to regions works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants