How to save multi-page tiff into database?

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
jsun
Posts: 5
Joined: Tue Sep 23, 2008 8:30 am

How to save multi-page tiff into database?

Post by jsun » Fri Oct 10, 2008 1:03 am

Hi,

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

Thanks,

Jimmy

Alex
Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

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

Post by Alex » Fri Oct 10, 2008 1:36 pm

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

robl
Posts: 2
Joined: Thu Oct 23, 2008 8:53 pm

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

Post by robl » Thu Oct 23, 2008 8:56 pm

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

Alex
Site Admin
Posts: 1443
Joined: Thu Jul 10, 2008 2:21 pm

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

Post by Alex » Fri Oct 24, 2008 9:37 am

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

robl
Posts: 2
Joined: Thu Oct 23, 2008 8:53 pm

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

Post by robl » Fri Oct 24, 2008 5:50 pm

Thanks Alex!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest