Click here to Skip to main content
Click here to Skip to main content

Scan2PDF

By , 22 Apr 2005
 
Prize winner in Competition "MFC/C++ Mar 2005"

Figure 1

Introduction

Several months ago, one of my clients asked me for creating a simple utility for his bulk scanning process. Also he wanted to save the scanned documents into PDF and then burn them on CD/DVD for archiving.

After some research on the Net, I decided to combine various free and open source libraries. Here is list of them:

  1. PDFLib Lite version. Please read the license carefully. You can use the library for personal usage only, not commercial.
  2. Nero Burning CD/DVD SDK/API. Please read the license carefully.
  3. CxImage lmaging toolkit. Thanks to Davide Pizzolato for sharing his knowledge and efforts.
  4. TWAIN C++ wrapper. Thanks to Rajiv Ramachandran for his article.

Scan2PDF Application

The program is very simple to use. I created a wizard style application that anyone can work with it very easily. Most of the task will be done by program itself and the user only sets the configuration. The above figure shows the first screen of the wizard.

The second screen of wizard asks the user for entering a project name. The application should scan bulk of images, converts scanned images to PDF then burn all PDFs in CD/DVD. However if in middle of scanning/converting process, user decides to leave his desk, what happens. The wizard solves this. Just scan your documents, save them into PDF and whenever you want, you can save your project (going to last page of wizard and click on Finish). After returning, you can open your previous saved projects. The combo box of second page of wizard shows all of projects. See figure 2 for more information.

Figure 2

This is not a tutorial of how to create such kind of this application. But you can take a look at source code and learn by yourself. Also both PDFLib and Nero SDK have an extensive documentation on how to use the libraries. For having some idea of how you can use PDFLib, my other article Text2PDF is another good starting point.

OK, I use CxImage library for creating TIFF files on the fly. You can modify the code to create JPEG files (the PDFLib supports both formats). For scanning purposes, I use the C++ TWAIN wrapper written by Rajiv. Both of articles have good examples of how to employ the code.

Just select your scanner source, click on "Scan New Documents" and after several scans to convert all the scanned documents into PDF, click on "Convert To PDF" button. The progress bar will show progress of converting. After creating the PDF, by clicking on "Scan New Documents" and then "Convert To PDF", you will have separate PDF file.

Figure 3

If you want to know which documents were scanned by you, just click on "Scanned Documents". A dialog will be appear and shows list of PDFs.

Figure 4 shows the next step of wizard. The combo box shows list of available CD Drives including your CD Burner. You have the option for burning the CD or simulate the burning process. If you want to create an image of CD (such as ISO), I have written some code for you, but commented it. You can uncomment the codes and create your own CD image of scanned/PDF documents.

Figure 4

The last step is very simple to use. You have two options. One for launching the wizard again for another wizard and one for deleting the current project (and its PDFs) as shown in Figure 5.

Figure 5

I hope this utility becomes useful for someone and also many people can benefits from it or its source code.

Enjoy!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

A. Riazi

Iran (Islamic Republic Of) Iran (Islamic Republic Of)
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acqusition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competetion, my articles are:

You can see list of my articles, by clicking here


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionusage on a website?memberKalpana Volety11-Jan-13 11:54 
Can you please give us an example on how to use the application in a web environment like asp.net?
 
Thanks a lot in advance,
Kalpana Volety
PDF tools Online
AnswerRe: usage on a website?memberA. Riazi11-Jan-13 21:16 
You can upload images then convert them to PDF. For burning to CD/DVD, you have to use some type of ActiveX component.
 
BR/ A. Riazi
GeneralRe: usage on a website?memberKalpana Volety11-Jan-13 22:21 
thank you.
 
Kalpana
GeneralMy vote of 5membermanoj kumar choubey26-Feb-12 19:43 
Nice
Generalfor nero hookmemberjepson li11-Nov-08 22:07 
Hi Riazi,
 
Thanks for giving us the nice porgram, I just enjoy it.
Recently I try to hook NeroBurn(...) to record the nero.exe behavior,unfortunately,it can't work,
But It can record the program using NeroApi SDK developed.
Does nero.exe use NeroBurn(...) function? How can I get the behavior of nero.exe?
 
Thanks
 
Jepson
QuestionHow can I use this in ASP.NET applicationmemberpbansal20-Jan-08 21:14 
I am looking for a .Net wrapper to be used in ASP.NET application where the user at the client machine browsing the application in IE, shouls be able to scan the document and directly upload/save the scan pdf files to Server.
 
If anyone got some idea. I would like to know.
 
Thanks for the help.
 
Regards
 
Pawan
GeneralExample in .NetmemberAtwal Darshan15-Feb-07 2:44 
Hi,
 
I will be helpfull if you can help me to create the similar functionality in .net.
 
I just want to scn multiple documents using ADF feature on a single click, can you help me.
 
darshan
GeneralGood Work!memberbaogangfeng20-Dec-06 19:18 
Rose | [Rose] Exellent!
I am searching documents about nero sdk.
 
But the link to nero sdk is bad one, version 1.6 is available, it is ftp://ftp6.nero.com/NeroSDK-v1.06.zip[^]
 
Thanks.
GeneralSalammemberasef10-Dec-06 2:28 
Salam
In a project I have to Wirte some file on CD. How can I use your code in a simple Dialog project.
I missed you!
 
ThanksSmile | :)
 
MOSTAFA

GeneralRe: SalammemberA. Riazi10-Dec-06 3:37 
Use Nero SDK, there are various examples.
 
Best regards,
Abbas
QuestionHELP,HELP!!!!memberalphawiw4-Nov-06 8:17 
I use PDFlib ,but Why I get the errors like:
PDFDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall PDFlib::~PDFlib(void)" (??1PDFlib@@QAE@XZ)
PDFDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall PDFlib::PDFlib(void * (__cdecl*)(struct PDF_s *,unsigned int,char const *),void * (__cdecl*)(struct PDF_s *,void *,unsigned int,char const *),void (__cdecl*)(struct PDF_s *,v
oid *),void *)" (??0PDFlib@@QAE@P6APAXPAUPDF_s@@IPBD@ZP6APAX0PAXI1@ZP6AX03@Z3@Z)
 
What should I do???
Please Help Me!!!!!
 
alphawiw

GeneralHello againmemberIranian21-Oct-06 11:40 
Salam dosteh Aziz Mr. Riazi,
 
I see that you are still pretty active. How is Shiraz these days...? Are your books published in Iran?Cool | :cool:
 
Regrads,
 
Bijan G.
GeneralRe: Hello againmemberA. Riazi21-Oct-06 22:07 
Salam,
Happy to hear from you again. Shiraz is pretty sunny these days. What do you do? What about your bussiness?
Yes, I have published 7 books in Iran.
 
Best regards,
A. Riazi

GeneralRe: Hello againmemberIranian27-Oct-06 16:58 
I am a "Mashadi" engineer living in US. Have lived here for the past 30 years. I started in hardware design and ended in software. I am well versed with a lot of Microsoft technologies... I teach and consult for living. I too have thought about writing... I also like teaching... It keeps you on the leading/bleeding (?) edge of the technology and I meet a lot of bright people.
 
Regards,
 
Bijan G.
JokeI am so happymembermohamadhamedi6-Jul-06 7:15 
hello
 
i am very intrested to see iranian programmer here.
 
could you put a component to use in .net program??
 
thanks
 
mohamad hamedi
AnswerRe: I am so happymemberA. Riazi6-Jul-06 20:11 
Salam,
Thanks for your comment.
May be in near future, I rewrite it as .NET component.
 
Best regards,
A. Riazi

GeneralBroken linkmemberAlexEvans20-Jun-06 16:23 
Hello there
 
Nice job, thanks for sharing
 
It seems the link to the Nero SDK is gone... Can you email me another link or that SDK please?
 
Thanks
Alex
 
aevans@leading.com.au
AnswerRe: Broken linkmemberA. Riazi23-Jun-06 0:27 
Download the SDK from here[^].
 
Best regards,
A. Riazi

GeneralRe: Broken linkmemberbaogangfeng20-Dec-06 19:23 
Version 1.6 of Nero sdk is available, it is ftp://ftp6.nero.com/NeroSDK-v1.06.zip[^]
GeneralEmail Capabilitymemberbickyb8-Apr-06 8:51 
Hi there,
This is a pretty cool app. I had some questions about it. Can you scan multiple pages and then have them combined as one PDF?
 
Also, do I have to burn to CD or can I just save my PDFs to disk?
 
Also, a cool feature that you might add is email capability, where one can email pdfs to another person(s).
 
Thanks,
Bicky
AnswerRe: Email CapabilitymemberA. Riazi23-Jun-06 0:33 
Hi,
1- With this utility you can scan multiple pages and save as a single PDF.
2- You can avoid burning if you want.
3- email is good option but unfortunately have not time to do this.
 
Best regards,
A. Riazi
 

GeneralhimemberThe_Myth21-Mar-06 3:09 
Hi how are you
Thanks a lot for you articles it's very good
But I think this like is expired
 
• Download PDFLib library - 5.82 MB
• Download Nero SDK - 3.57 MB
Can you send this 2 file for my email
Thanks again
And keep the good work
Big Grin | :-D
 

 
AMH
Software Developer
LIFE'S SHORT. If you don't look around once in a while you might miss it

 

AnswerRe: himemberDrucik_21-Jan-07 7:17 
google is your friend Roll eyes | :rolleyes:
 
Newest version of Nero SDK - http://www.nero.com/nero7/eng/SDK_API.html
PDFLib - http://www.pdflib.com/download/
Big Grin | :-D
 

 
-----------------------------------------------------------------
Surely without war there would be no loss
Hence no mourning, no grief, no pain, no misery
No sleepless nights missing the dead... Oh, no more
No more war
 
[Sleepless - Cradle of Filth]

GeneralRe: himemberThe_Myth22-Jan-07 0:02 
:->
thanks
have nice day
 
AMH
Software Developer
MCP
LIFE'S SHORT. If you don't look around once in a while you might miss it

 

JokeVery Thoughtful Effort!membereaster_200720-Feb-06 15:49 
I am from the USA, of course you might know that everything we make when it comes to showing our efforts here is always scrutinized and looked over with different views.
 
Well, that always boils down to who is doing the looking or can offer the most acceptable responses.
 
I just want to add as a first reply in 2006 that your code and project is very appealling. Nice Job!!
 
The experience in your years to programming shows up nicely in the Code Project article.
 
Thanks for sharing and keep at it. EASTER:::::::->
 

AnswerRe: Very Thoughtful Effort!memberA. Riazi21-Feb-06 5:21 
Thanks so much for your comments.
 
Best regards,
A. Riazi
GeneralScan2PDF wrapper in .NETmemberVINH TRAN8-Sep-05 14:32 
Hi,
 
I really like your software. I would like to integrate to my software which was written in .NET. Do you have a .NET version. Excellent program.
 
Vinh
 
Vinni
GeneralEncoding Scanned Signaturememberrakesh23831-Aug-05 2:32 
Hi A. Riazi ,
Excellent work , its really good.
However i wanted to know whether is it possible to "Encrypt a scanned image of handwritten signature ,to secure it so that whenever any unauthorised user want to open it the signature remain hidden , while the other part of document can be displayed as it is"


 
Thanks
Rakesh....
GeneralRe: Encoding Scanned SignaturememberA. Riazi1-Aug-05 4:06 
Hi,
Yes and No! Yes because you can set some password that those who have the password can see the document and No because you can't create a PDF that some part of it are visible to users and some part depends on permissions.
 
Best regards,
A. Riai

QuestionActiveX???memberTaha Zayed23-May-05 9:32 

I need an ActiveX component to scan images client side to use it in a asp.net web application.
Can you help me?
AnswerRe: ActiveX???memberA. Riazi23-May-05 9:45 
Read this article: C++ TWAIN Wrapper[^]
 
Best regards,
A. Riazi
GeneralRe: ActiveX???memberTaha Zayed23-May-05 9:49 
thanks for fast reply
but i need ActiveX component written in native code so user(client) will not have to install dot net framework at allFrown | :(
GeneralRe: ActiveX???memberA. Riazi23-May-05 10:02 
I'm sorry but I have not enough time to do it for you. You can search the net, may be you find something.
 
Best regards,
A. Riazi
GeneralRe: ActiveX???memberTaha Zayed29-May-05 21:21 
check this
http://www.codeproject.com/useritems/Web_Twain.asp[^]
GeneralRe: ActiveX???memberpbansal20-Jan-08 21:02 
I am also looking for a .Net wrapper to used in ADSP.NET application where the user at the client machine browsing the application in IE, can directly save the scan pdf files to Server.
 
If anyone got some idea. I would like to know.
 
Thanks for the help.
 
Regards
 
Pawan
GeneralRe: ActiveX???memberpbansal20-Jan-08 21:05 
I am also looking for a .Net wrapper to used in ASP.NET application where the user at the client machine browsing the application in IE, can directly save the scan pdf files to Server.
 
If anyone got some idea. I would like to know.
 
Thanks for the help.
 
Regards
 
Pawan
Questiononly works with static linking ????memberbevpet6-May-05 14:14 
Hi,
superb effort and application.
 
tried to incorporate your code into my app which is using a shared "mfc dll",
any change to get this to work with a "shared mfc dll" ?? and using visual studio dev environment 2003:
 
do i need updated pdflibs from pdflib.com or should i recompile them ??
---------------------------------------------------------------
 
d:\mstools\PDFLib\pdflib.hpp(52) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
d:\mstools\PDFLib\pdflib.hpp(59) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
d:\mstools\PDFLib\pdflib.hpp(60) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
d:\mstools\PDFLib\pdflib.hpp(62) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
d:\mstools\PDFLib\pdflib.hpp(64) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
d:\mstools\PDFLib\pdflib.hpp(65) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
d:\mstools\PDFLib\pdflib.hpp(67) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
 

------------------------------------------------------------
 
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::close(void)" (?close@PDFlib@@QAEXXZ) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::end_page_ext(class std::basic_string,class std::allocator >)" (?end_page_ext@PDFlib@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::close_image(int)" (?close_image@PDFlib@@QAEXH@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::fit_image(int,double,double,class std::basic_string,class std::allocator >)" (?fit_image@PDFlib@@QAEXHNNV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::begin_page_ext(double,double,class std::basic_string,class std::allocator >)" (?begin_page_ext@PDFlib@@QAEXNNV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: int __thiscall PDFlib::load_image(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >)" (?load_image@PDFlib@@QAEHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::set_info(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >)" (?set_info@PDFlib@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: __thiscall PDFlib::~PDFlib(void)" (??1PDFlib@@QAE@XZ) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: int __thiscall PDFlib::open_file(class std::basic_string,class std::allocator >)" (?open_file@PDFlib@@QAEHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: void __thiscall PDFlib::set_parameter(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator >)" (?set_parameter@PDFlib@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
ScannerPage.obj : error LNK2019: unresolved external symbol "public: __thiscall PDFlib::PDFlib(void * (__cdecl*)(struct PDF_s *,unsigned int,char const *),void * (__cdecl*)(struct PDF_s *,void *,unsigned int,char const *),void (__cdecl*)(struct PDF_s *,void *),void *)" (??0PDFlib@@QAE@P6APAXPAUPDF_s@@IPBD@ZP6APAX0PAXI1@ZP6AX03@Z3@Z) referenced in function "protected: void __thiscall CScannerPage::OnConvertToPDF(void)" (?OnConvertToPDF@CScannerPage@@IAEXXZ)
 

Thanks
Peter

AnswerRe: only works with static linking ????memberA. Riazi6-May-05 17:55 
I used two libraries: PDFLib and CxImage. You must change to them to be compatible with your project.
 
Best regards,
A. Riazi
GeneralRe: only works with static linking ????memberbevpet9-May-05 6:55 
Mr Riazi,
 
go it to work with my project finally, had to get in contact with the people at pdflib...
 
i needed to bind to pdflib.cpp in order to prevent the errors from occuring. so scan2pdf is working in a shared mfc dll environment.
 
thanks for the excellent article.
 
Peter
GeneralRe: only works with static linking ????memberA. Riazi9-May-05 7:06 
Smile | :)
 
If you like my article please vote me for best article of month competition here: http://www.codeproject.com/script/survey/survey.asp?survey=463[^]
GeneralDAMET GARMsussBobbyQSoft29-Apr-05 2:28 
Bebin...man America hastam...va dar computer hastam.....goosh meekoni?
 
meekham baram kar koni az iran...khoob behet pool meedam, vali mesle khar azat kar meekesham....
 
Az in article khosham omad, vali jenab e kheng ali, chera file DLL e NERO ro nazashti? Khasisit omad?
 
Movazeb e khodet bash...va behem begoo ke chegadar pool meegiri baray e consulting
GeneralRe: DAMET GARMmemberA. Riazi29-Apr-05 2:54 
I saw your comment and also got an email notification from you but your email address is very strange! Is it real? OMG | :OMG:
About Nero dll, because of copyright I didn't copy it into demo/project!
OK, please provide me your real email address/name and also describe more about the job. Is it require any programming or only consulting?
 
Best regards,
A. Riazi
GeneralExcellent!memberProfessor C++28-Apr-05 23:29 
You got my 5!
 

GeneralRe: Excellent!memberBig Al R3-May-05 20:29 
And I'll add my 5. Interesting and also fills that hole one my "not so modern" system. Only thing missing IMHO is multipage capability, but there are tools like Pdftk (GPL) to do the job of concatenating. Well done.
 
Alan
GeneralRe: Excellent!memberA. Riazi5-May-05 6:21 
Thanks for your comment.
 
Best regards,
A. Riazi
GeneralRe: Excellent!membermarkgreville17-May-05 1:00 
5 from me as well!
 
Well written!
 
Mark
GeneralRe: Excellent!memberA. Riazi17-May-05 1:06 
Thanks for your 5!
If you like my article, please vote me for best article of month competition here: April Best Article of Month Competition[^]
 
Best regards,
A. Riazi

GeneralRe: Excellent!membermarkgreville17-May-05 1:09 
Done!
GeneralRe: Excellent!memberA. Riazi17-May-05 1:12 
Thanks! Smile | :)
 
A. Riazi

GeneralRe: Excellent!memberKW-Rix20-May-05 4:43 
Add My 5 More as as well !!
 
Well Done !! ^_^
 
Rix
 
KW-Rix

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130617.1 | Last Updated 23 Apr 2005
Article Copyright 2005 by A. Riazi
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid