Page 1 of 2

Scanning pdf file to SQL Server

Posted: Thu Oct 16, 2008 6:33 pm
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?

Re: Scanning pdf file to SQL Server

Posted: Fri Oct 17, 2008 8:47 am
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

Re: Scanning pdf file to SQL Server

Posted: Mon Oct 20, 2008 2:34 am
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.

Re: Scanning pdf file to SQL Server

Posted: Mon Oct 20, 2008 8:13 am
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

Re: Scanning pdf file to SQL Server

Posted: Mon Oct 20, 2008 4:17 pm
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.

Re: Scanning pdf file to SQL Server

Posted: Mon Oct 20, 2008 4:28 pm
by Alex
You should use the following code:

Code: Select all

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

Re: Scanning pdf file to SQL Server

Posted: Fri Jan 09, 2009 7:13 pm
by BillG
Can you please show me the code for acquiring the image as a pdf and saving it to SQL Sever?

Bill

Re: Scanning pdf file to SQL Server

Posted: Fri Jan 09, 2009 8:33 pm
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

Re: Scanning pdf file to SQL Server

Posted: Fri Jan 09, 2009 10:36 pm
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?

Re: Scanning pdf file to SQL Server

Posted: Sat Jan 10, 2009 12:55 am
by BillG
Solved it. Again, a great product. Well worth, the money.