I'm getting indices are out of range error from the "convertToBlob" method of dynamic Web twain, Im using it to scan documents via scanner, can anyone help?
dwObject.ConvertToBlob([0], EnumDWT_ImageType.IT_JPG, (result) => {
const data = new File([result], 'Scan.jpeg', result);
let attachmentsBlob = [];
let attachmentObject = [];
directAccess ? attachmentObject.push({ attachmentName: "Scan.jpeg", attachmentType: parentType, documentType: type }) : attachmentObject.push({ attachmentName: "Scan.jpeg", attachmentType: type });
attachmentsBlob.push(data);
this.customerAttachment(attachmentObject, attachmentsBlob).subscribe((res: any) => {
if (res['code'] === '0000') {
this.toastr.success("Attachement uploaded Successfully");
if (directAccess) {
form.patchValue(res.data[0]);
} else {
let scan = form.controls.customerAttachments.value;
scan.push(res.data[0]);
form.controls.customerAttachments.setValue(scan);
}
} else if (res['code'] === '0101') {
this.toastr.error('Error', res['data']['message']);
}
});
}, (errorCode, errorString) => {
this.toastr.error(errorString);
});
Not sure how you wrote your code. As long as you have scanned documents in memory, you won't get this issue.
Here is a simple example of Dynamic Web TWAIN v17.1 (the namespace is different from yours), demonstrating how to use
ConvertToBlob
: