Scanning pdf file to SQL Server
Moderator: Alex
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Scanning pdf file to SQL Server
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?
-
- Site Admin
- Posts: 2401
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Scanning pdf file to SQL Server
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
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
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Re: Scanning pdf file to SQL Server
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.
-
- Site Admin
- Posts: 2401
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Scanning pdf file to SQL Server
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
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
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Re: Scanning pdf file to SQL Server
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.
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.
-
- Site Admin
- Posts: 2401
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Scanning pdf file to SQL Server
You should use the following code:
Best regards, Alexander
Code: Select all
MemoryStream mem = VSTwain1.GetImageAsStream(0, ImageFileFormat.PDF);
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Re: Scanning pdf file to SQL Server
Can you please show me the code for acquiring the image as a pdf and saving it to SQL Sever?
Bill
Bill
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Re: Scanning pdf file to SQL Server
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
Bill
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Re: Scanning pdf file to SQL Server
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?
-
- Posts: 47
- Joined: Fri Oct 10, 2008 3:52 pm
Re: Scanning pdf file to SQL Server
Solved it. Again, a great product. Well worth, the money.