Scanning pdf file to SQL Server

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

Moderator: Alex

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Scanning pdf file to SQL Server

Post by BillG » Thu Oct 16, 2008 6:33 pm

My client wants to convert the image scanned in to a pdf file and then save the pdf file to a table in SQL Server. How would I do that?

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

Re: Scanning pdf file to SQL Server

Post by Alex » Fri Oct 17, 2008 8:47 am

Hello Bill,

Do you need to store each image as a single PDF document or store all images as a multipage PDF document?

Current version of library allows to save only the single image to the stream using the GetImageAsStream method. We will add ability to add image to an existing PDF document stored in the stream in next version of library.

Best regards, Alexander

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Scanning pdf file to SQL Server

Post by BillG » Mon Oct 20, 2008 2:34 am

Each image is a separate document. They are scanning membership cards. So they look up the member's record and on the member form is a button for scanning documents, they click the scan button, I read the image into memory and then I want to save it to a table called memberdocuments along with the Social Security number of the member. The pdf will be stored I am assuming in a image or a binary field. Later on I can retrieve the pdf record and display it in a pop up window to the user.

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

Re: Scanning pdf file to SQL Server

Post by Alex » Mon Oct 20, 2008 8:13 am

Hello Bill,

In this case you can use the GetImageAsStream method - save acquired image as a PDF document to a stream and save stream into the database.

Best regards, Alexander

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Scanning pdf file to SQL Server

Post by BillG » Mon Oct 20, 2008 4:17 pm

Can you show me the code for that? This is what I am using right now.

Bitmap dib = (Bitmap)vsTwain1.GetImage(0);
MemoryStream mem = new MemoryStream();
dib.Save(mem, ImageFormat.Bmp);

then i assigned to the save parameter the following mem.getBuffer();

The only problem is that it keeps timing out as I do the save.

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

Re: Scanning pdf file to SQL Server

Post by Alex » Mon Oct 20, 2008 4:28 pm

You should use the following code:

Code: Select all

MemoryStream mem = VSTwain1.GetImageAsStream(0, ImageFileFormat.PDF);
Best regards, Alexander

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Scanning pdf file to SQL Server

Post by BillG » Fri Jan 09, 2009 7:13 pm

Can you please show me the code for acquiring the image as a pdf and saving it to SQL Sever?

Bill

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Scanning pdf file to SQL Server

Post by BillG » Fri Jan 09, 2009 8:33 pm

I don't mean the code to save the file in the table but the part where I acquire the image from the scanner and convert it to the type to save to an image field in the table.

Bill

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Scanning pdf file to SQL Server

Post by BillG » Fri Jan 09, 2009 10:36 pm

Ok I think that I figured out how to save it properly in the table. Now how do I display it as a pdf file on a form?

BillG
Posts: 47
Joined: Fri Oct 10, 2008 3:52 pm

Re: Scanning pdf file to SQL Server

Post by BillG » Sat Jan 10, 2009 12:55 am

Solved it. Again, a great product. Well worth, the money.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest