Hi,
Is it possible to save multipage PDFs from web twain using javascript+vb.net?
Thanks.
Multipage PDFs from web twain
Moderator: Alex
Re: Multipage PDFs from web twain
Hello,
Yes, this is possible.
First, you need to save all acquired images as PDF document in the stream - please read description of the AcquiredImage.GetAsStream method in the documentation or see this FAQ: http://www.vintasoft.com/vstwain-dotnet ... magesAsPdf
Next, you need to upload stream to the server - please read description of the HttpUpload.AddFileField method in the documentation.
Best regards, Alexander
Yes, this is possible.
First, you need to save all acquired images as PDF document in the stream - please read description of the AcquiredImage.GetAsStream method in the documentation or see this FAQ: http://www.vintasoft.com/vstwain-dotnet ... magesAsPdf
Next, you need to upload stream to the server - please read description of the HttpUpload.AddFileField method in the documentation.
Best regards, Alexander
Re: Multipage PDFs from web twain
Hi, thanks for your answer.
I tried both examples from FAQs and from help documentation for GetAsStream Method.
If I’m following FAQ example, I’m getting error “AquiredImgae.0 is null or not an object” and device.AcquiredImages.Count is always 1 even if I’ve scanned 10 pages.
Help documentation example gives me error “ImageFileFormat is undefined”
Thanks.
if (acquireModalState == 2) {
if (firstImage) {
// get the first image as PDF stored in the memory
mem = device.AcquiredImage[0].GetAsStream(ImageFileFormat.PDF);
firstImage = false;
}
else {
// add image to PDF stored in the memory
for (var x=1; x=device.AcquiredImages.Count-1; x++) {
device.AcquiredImages[x].SaveToStream(mem, ImageFileFormat.PDF);
}
}
}
I tried both examples from FAQs and from help documentation for GetAsStream Method.
If I’m following FAQ example, I’m getting error “AquiredImgae.0 is null or not an object” and device.AcquiredImages.Count is always 1 even if I’ve scanned 10 pages.
Help documentation example gives me error “ImageFileFormat is undefined”
Thanks.
if (acquireModalState == 2) {
if (firstImage) {
// get the first image as PDF stored in the memory
mem = device.AcquiredImage[0].GetAsStream(ImageFileFormat.PDF);
firstImage = false;
}
else {
// add image to PDF stored in the memory
for (var x=1; x=device.AcquiredImages.Count-1; x++) {
device.AcquiredImages[x].SaveToStream(mem, ImageFileFormat.PDF);
}
}
}
Re: Multipage PDFs from web twain
Hello,
Best regards, Alexander
Your code has 3 mistakes:Help documentation example gives me error “ImageFileFormat is undefined”
- Wrong name of property in the line "mem = device.AcquiredImage[0].GetAsStream(ImageFileFormat.PDF);". You need to use "AcquiredImages" instead of "AcquiredImage".
- JavaScript cannot access Indexer of class, i.e. line "device.AcquiredImages[0]" is not correct in JavaScript
- JavaScript does not know anything about the ImageFileFormat enumeration. Here are constants of ImageFileFormat enumeration: BMP - 0, JPEG - 1, TIFF - 2, PNG - 3, GIF - 4, PDF - 5.
Code: Select all
if (acquireModalState == 2)
{
if (firstImage)
{
// get the first acquired image as PDF stored in the memory
mem = device.AcquiredImage[0].GetAsStream(5);
firstImage = false;
}
else
{
// add each (not first) acquired image to PDF stored in the memory
device.AcquiredImages.Last.SaveToStream(mem, 5);
}
}
Re: Multipage PDFs from web twain
Alex, we have tried implementing the suggested code, but it seems not to work.
Our scanner is a single page scanner, but we would like to scan multiple images into a single document.
With the suggested code, after the first scan, the device.AcquireModal() method returns 3, after which the image is uploaded. Is there anyway to achieve the above?
Our scanner is a single page scanner, but we would like to scan multiple images into a single document.
With the suggested code, after the first scan, the device.AcquireModal() method returns 3, after which the image is uploaded. Is there anyway to achieve the above?
Re: Multipage PDFs from web twain
Hello,
Value 3 means that scan is completed i.e. you acquired image from flatbed scanner.
You should save acquired image to the stream, start the second/third/... scan, add acquired images to the stream, upload data of the stream to the server when this is necessary.
Best regards, Alexander
Value 3 means that scan is completed i.e. you acquired image from flatbed scanner.
You should save acquired image to the stream, start the second/third/... scan, add acquired images to the stream, upload data of the stream to the server when this is necessary.
Best regards, Alexander