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 »

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: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Scanning pdf file to SQL Server

Post by Alex »

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 »

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 * 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: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Scanning pdf file to SQL Server

Post by Alex »

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 »

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: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: Scanning pdf file to SQL Server

Post by Alex »

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 »

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 »

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 »

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 »

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