I'm uploading the scanned images as PDF through the HttpUpload_AddFileField and what I noticed is that when I check the files in the database only the first file is recognized as PDF and the rest are corrupted. Because there is no functionality yet to upload all the images as one PDF multipage file in the VintaSoft twain driver( pending to be provided) I used the ITextSharp to merge the PDF files into one PDF file when I get the HTTP response ( or request). It gives me an error that the header could not be found, so I changed the code to store each file individually into the database table so I can check if I can open all of them, and only the first file opens correctly and I can see the scanned image, but the rest does not open, it gives me an error :
"Adobe Acrobat Reader DC could not open [filename] because it is either not a supported file type or because the file has been damaged".
If I do a select statement on the database (SQL Server 2008) and just by viewing the binary column I see for the first file the text representation of the binary file 0x255.........(PDF) the rest I see the 0x00000......
furthermore, before saving a file to the database I do a compare to see if I'm not saving an empty binary, all files are stored in the database. all saved files gives me a 380 KB size, including the first one that I can open, so this means that the rest of the files have data.
The code I'm using to upload the scanned images is the following and the imageFormat variable is = 'PDF':
Code: Select all
function UploadToHttpServer() {
if (VSActiveX4Scan.Error) {
} else {
if (VSActiveX4Scan.HttpUpload_SetServerParams('" + PostImageUrl + "',''," + Site.ActiveXConnectionTimeout + ") == 0) {
alert(""Image could not be transferred to server: "" + VSActiveX4Scan.ErrorString);
}
else {
var addResult = false;
//var imageFileName = '" + GUID + ".' + ImageFormat;
for (var i = 0; i < VSActiveX4Scan.AcquiredImages_Count; i++){
if(!VSActiveX4Scan.AcquiredImages_IsBlank(i, 0.01, 0)) {
if (VSActiveX4Scan.AcquiredImages_Despeckle(i, " + Site.SmallNoise + ", " + Site.MediumNoise + ", " + Site.Radius + ", " + Site.BorderNoise + ") == 0) {
//error
}
if (VSActiveX4Scan.AcquiredImages_Deskew(i, " + Site.BorderColor + ", " + Site.ScanIntervalX + "," + Site.ScanIntervalY + ") == 0) {
//error
}
if (VSActiveX4Scan.AcquiredImages_DetectBorder(i, " + Site.BorderSize + ") == 0) {
document.getElementById('" + "').innerHTML += VSActiveX4Scan.errorString;
}
//each scanned image will be send to the server separately
var imageFileName = 'Image' + i + '.' + ImageFormat;
if (VSActiveX4Scan.HttpUpload_AddFileField('file', imageFileName, i) == 0) {
alert(""Image"" + (i + 1) + ""cannot be uploaded: "" + VSActiveX4Scan.ErrorString);
}
else {
addResult = true;
}
if (!addResult) {
alert(""No images to upload."");
return;
}
}
}
if (VSActiveX4Scan.HttpUpload_PostData() == 0) {
alert(VSActiveX4Scan.ErrorString);
return;
}
setTimeout('UploadStatus()',10);
}
}
}
function UploadStatus() {
var statString = VSActiveX4Scan.HttpUpload_StateString
if (VSActiveX4Scan.HttpUpload_State == 4)
statString = statString + ' Uploaded ' + String(VSActiveX4Scan.HttpUpload_BytesUploaded) + ' bytes from ' + String(VSActiveX4Scan.HttpUpload_BytesTotal) + ' bytes.';
if ((VSActiveX4Scan.HttpUpload_State == 6) || // Aborting
(VSActiveX4Scan.HttpUpload_Status == 5) || // Completed
(VSActiveX4Scan.HttpUpload_Status == 0) || // None
(VSActiveX4Scan.HttpUpload_ErrorCode != 0)) {
if (VSActiveX4Scan.HttpUpload_ErrorCode == 0) {
if (VSActiveX4Scan.HttpUpload_ResponseCode == 200) {
// succesfull upload, no need to notify.
}
else {
alert(""Response code: "" + VSActiveX4Scan.HttpUpload_ResponseCode);
alert(""Response string: "" + VSActiveX4Scan.HttpUpload_ResponseString);
}
VSActiveX4Scan.HttpUpload_ClearAllFileFields();
if (VSActiveX4Scan.Device_State == 0) {
CloseDeviceAndManager();
}
uploadEnded = true;
} else {
//error
alert(""Error: "" + VSActiveX4Scan.HttpUpload_ErrorString);
}
}
else
setTimeout(""UploadStatus()"",1);
}
Thanks in advance