Page 1 of 1

How to save multi-page tiff into database?

Posted: Fri Oct 10, 2008 1:03 am
by jsun
Hi,

I like to scan multiple pages and save as multi-page tiff file (single file) back to database. Is it possible?

Thanks,

Jimmy

Re: How to save multi-page tiff into database?

Posted: Fri Oct 10, 2008 1:36 pm
by Alex
Hello Jimmy,

Current version of library allows to save only the single image to the stream using the GetImageAsStream method. Please add your suggestion to the "New features request..." topic and we will add opportunity to save all images into the single stream.

At the moment you should save all images to a mutipage TIFF on a disk and then save file from disk to database.

Best regards, Alexander

Re: How to save multi-page tiff into database?

Posted: Thu Oct 23, 2008 8:56 pm
by robl
Hi Alex,

I'm trying to save a multi-file tiff to disk and read it back to store into DB as you've suggested. I have a duplex printer and using Advanced Sample, Save As..., Multi-Tiff does not save both pages to the tiff (using fax tiff viewer and it shows only one page)

Can you please provide a sample of how to save a multi-file tiff to disk and read it back to save to DB as you've suggested.

Thanks in advance

Re: How to save multi-page tiff into database?

Posted: Fri Oct 24, 2008 9:37 am
by Alex
Hello,

You can save acquired image(s) to a stream as multipage TIFF file or PDF document and further save stream data to database.

Here is an example that shows how to save each acquired image as a separate PDF document in a stream:

Code: Select all

Dim mem As MemoryStream = VSTwain1.GetImageAsStream(0, ImageFileFormat.PDF)
And here is an example that shows how to save all acquired images as a single PDF document in a stream:

Code: Select all

Public Sub ScanWithUI()
    Dim mem As MemoryStream    
    VSTwain1.AppProductName = "MyTwainApplication"
    Try
        VSTwain1.StartDevice()
        VSTwain1.SelectSource()
        VSTwain1.ShowUI = true
        VTwain1.MaxImages = 1
        Dim firstImage As Boolean = True
        While VSTwain1.AcquireModal()
            If firstImage Then
                ' Create memory stream and place the first image to it
                mem = VSTwain1.GetImageAsStream(0, ImageFileFormat.PDF)
                firstImage = False
            Else
                ' Add second and next images to the stream
                VSTwain1.SaveImageToStream(0, mem, ImageFileFormat.PDF)
            End If
        End While
    Catch ex As TwainException
        MsgBox ex.Message
    Catch ex As ImagingException
        MsgBox ex.Message
    End Try
    ...
    ' Upload stream data to server or something else...
    ...
End Sub
Best regards, Alexander

Re: How to save multi-page tiff into database?

Posted: Fri Oct 24, 2008 5:50 pm
by robl
Thanks Alex!