MultiPage Scanning tweak...
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
MultiPage Scanning tweak...
YAY! I successfully got Open Dental to scan multiple pages into a pdf file and automatically import that file using TWAIN. This means the twain enabled fujitsu scanners will work with twain and do multiple pages at a time. This just shows how cool it is to have the source code to your software. I could name that ScanMultiPage anything... kinda neat. Not bad for a guy who doesnt know a thing about programming. I still have to test the Fujitsu next week at UCME4DK's office next week when I hook up his new Claris camera... But this is further then I have ever gotten on this before!
See the new icon on the Toolbar? MultiPageScan... Well the icon is the same but see the new description?
If you hit cancel, it will still try to import a pdf, so just hit cancel at the ItemInfo Window.
NOTE: EZTwain Pro is used which I believe is now free to anyone using OpenDental 5.4 and is on support (they are using a Binary version of Open Dental that was compiled by Open Dental)
Thanks to two people, one in Romania and the other in the UK and to Jordan for providing most the code!
http://www.codeguru.com/forum/showthread.php?t=442814
In the file ContrDocs.cs
http://www.koders.com/csharp/fid4D6F436 ... spx?s=zoom
The added code.
Line644
ToolBarMain.Buttons.Add(new ODToolBarButton(Lan.g(this, "ScanMultipage"), 5, Lan.g(this, "ImportPDF"), "ImportPDF"));
Line 993
case "ImportPDF":
OnImportPDF_Click();
break;
Line 1321
private void OnImportPDF_Click() {
File.Delete("C:\\image.pdf");
xImageDeviceManager.Obfuscator.ActivateEZTwain();
// Display TWAIN Select Source dialog
int wPIXTypes = EZTwain.SelectImageSource(this.Handle);
if (wPIXTypes == 0)
{//user clicked Cancel
return;
}
int j;
System.IntPtr hdib;
int N;
// Change this to your value:
N = 2;
EZTwain.SetHideUI(0);
EZTwain.SetJpegQuality(75);
if (EZTwain.OpenDefaultSource()==1)
{
EZTwain.SetResolution(100);
EZTwain.SetXferCount(N);
EZTwain.SetMultiTransfer(1);
if (EZTwain.BeginMultipageFile("c:\\image.pdf") == 0)
{
for (j = 1; j <= N; j++)
{
// If you can't get a Window handle, use IntPtr.Zero:
hdib = EZTwain.Acquire(this.Handle);
if (hdib == IntPtr.Zero)
{
break;
}
// <your image processing here>
EZTwain.DibWritePage(hdib);
EZTwain.DIB_Free(hdib);
}
EZTwain.EndMultipageFile();
}
EZTwain.CloseSource();
}
if (EZTwain.LastErrorCode() != 0)
{
EZTwain.ReportLastError("Unable to scan.");
}
OpenFileDialog openFileDialog=new OpenFileDialog();
openFileDialog.FileName = "c:\\image.pdf";
openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect=true;
string[] fileNames=openFileDialog.FileNames;
if(fileNames.Length<1){
return;
}
string nodeId="";
Document doc=null;
for(int i=0;i<fileNames.Length;i++){
bool copied = true;
try {
doc = imageStore.Import(fileNames, GetCurrentCategory());
}
catch(Exception ex) {
MessageBox.Show(Lan.g(this, "Unable to copy file, May be in use: ") + ex.Message + ": " + openFileDialog.FileName);
copied = false;
}
if(copied){
FillDocList(false);
SelectTreeNode(GetNodeById(MakeIdentifier(doc.DocNum.ToString(),"0")));
FormDocInfo FormD=new FormDocInfo(PatCur,doc,GetCurrentFolderName(TreeDocuments.SelectedNode));
FormD.ShowDialog();//some of the fields might get changed, but not the filename
if(FormD.DialogResult!=DialogResult.OK){
DeleteSelection(false);
}else{
nodeId=MakeIdentifier(doc.DocNum.ToString(),"0");
}
}
}
See the new icon on the Toolbar? MultiPageScan... Well the icon is the same but see the new description?
If you hit cancel, it will still try to import a pdf, so just hit cancel at the ItemInfo Window.
NOTE: EZTwain Pro is used which I believe is now free to anyone using OpenDental 5.4 and is on support (they are using a Binary version of Open Dental that was compiled by Open Dental)
Thanks to two people, one in Romania and the other in the UK and to Jordan for providing most the code!
http://www.codeguru.com/forum/showthread.php?t=442814
In the file ContrDocs.cs
http://www.koders.com/csharp/fid4D6F436 ... spx?s=zoom
The added code.
Line644
ToolBarMain.Buttons.Add(new ODToolBarButton(Lan.g(this, "ScanMultipage"), 5, Lan.g(this, "ImportPDF"), "ImportPDF"));
Line 993
case "ImportPDF":
OnImportPDF_Click();
break;
Line 1321
private void OnImportPDF_Click() {
File.Delete("C:\\image.pdf");
xImageDeviceManager.Obfuscator.ActivateEZTwain();
// Display TWAIN Select Source dialog
int wPIXTypes = EZTwain.SelectImageSource(this.Handle);
if (wPIXTypes == 0)
{//user clicked Cancel
return;
}
int j;
System.IntPtr hdib;
int N;
// Change this to your value:
N = 2;
EZTwain.SetHideUI(0);
EZTwain.SetJpegQuality(75);
if (EZTwain.OpenDefaultSource()==1)
{
EZTwain.SetResolution(100);
EZTwain.SetXferCount(N);
EZTwain.SetMultiTransfer(1);
if (EZTwain.BeginMultipageFile("c:\\image.pdf") == 0)
{
for (j = 1; j <= N; j++)
{
// If you can't get a Window handle, use IntPtr.Zero:
hdib = EZTwain.Acquire(this.Handle);
if (hdib == IntPtr.Zero)
{
break;
}
// <your image processing here>
EZTwain.DibWritePage(hdib);
EZTwain.DIB_Free(hdib);
}
EZTwain.EndMultipageFile();
}
EZTwain.CloseSource();
}
if (EZTwain.LastErrorCode() != 0)
{
EZTwain.ReportLastError("Unable to scan.");
}
OpenFileDialog openFileDialog=new OpenFileDialog();
openFileDialog.FileName = "c:\\image.pdf";
openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect=true;
string[] fileNames=openFileDialog.FileNames;
if(fileNames.Length<1){
return;
}
string nodeId="";
Document doc=null;
for(int i=0;i<fileNames.Length;i++){
bool copied = true;
try {
doc = imageStore.Import(fileNames, GetCurrentCategory());
}
catch(Exception ex) {
MessageBox.Show(Lan.g(this, "Unable to copy file, May be in use: ") + ex.Message + ": " + openFileDialog.FileName);
copied = false;
}
if(copied){
FillDocList(false);
SelectTreeNode(GetNodeById(MakeIdentifier(doc.DocNum.ToString(),"0")));
FormDocInfo FormD=new FormDocInfo(PatCur,doc,GetCurrentFolderName(TreeDocuments.SelectedNode));
FormD.ShowDialog();//some of the fields might get changed, but not the filename
if(FormD.DialogResult!=DialogResult.OK){
DeleteSelection(false);
}else{
nodeId=MakeIdentifier(doc.DocNum.ToString(),"0");
}
}
}
Last edited by Justin Shafer on Sat Jan 05, 2008 4:51 pm, edited 1 time in total.
- jordansparks
- Site Admin
- Posts: 5744
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Nicely done. There are a number of improvements that I can see that would need to be made before adding it. I can quickly make them, but then I don't have any way to test. I think what I will do is add part of this changes to 5.6, make the edits that I have in mind, and then post the new version here. You can take mine and paste it into what you have running to test it one more time.
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
Thanks! I will do anything you need me to do. I can either add your code into mine after a fresh download from svn... or I can wait on the 5.6...
I just know that I will be going to hook up the claris most likely tuesday... I can test it pretty easily just by asking an employee to load the scanner with paper remotely.. thats the office that was using dentrix and the fi-5110. http://www.youtube.com/watch?v=WwuesstIT8A
They have two scanners I think, so maybe I could ask to bring one home... It may be another office that has two snapscan's though...
Let me know what I need to do.
By the way in EZ Twain I told it I needed code to acquire images from a any twain device and then made it multipage. The FEEDER option may need to be called but the only way to really know is wait and test...
I just know that I will be going to hook up the claris most likely tuesday... I can test it pretty easily just by asking an employee to load the scanner with paper remotely.. thats the office that was using dentrix and the fi-5110. http://www.youtube.com/watch?v=WwuesstIT8A
They have two scanners I think, so maybe I could ask to bring one home... It may be another office that has two snapscan's though...
Let me know what I need to do.
By the way in EZ Twain I told it I needed code to acquire images from a any twain device and then made it multipage. The FEEDER option may need to be called but the only way to really know is wait and test...
- jordansparks
- Site Admin
- Posts: 5744
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Here are the minor changes. Are you able to easily test it to see if it still works?
Code: Select all
private void OnImportPDF_Click() {
xImageDeviceManager.Obfuscator.ActivateEZTwain();
// Display TWAIN Select Source dialog
int wPIXTypes = EZTwain.SelectImageSource(this.Handle);
if (wPIXTypes == 0){//user clicked Cancel
return;
}
int j;
System.IntPtr hdib;
int N;
N = 2; // Change this to your value
EZTwain.SetHideUI(0);
EZTwain.SetJpegQuality(75);
string filename=Path.GetTempFileName();
if (EZTwain.OpenDefaultSource()==1){
EZTwain.SetResolution(100);
EZTwain.SetXferCount(N); //js: I don't know what this is
EZTwain.SetMultiTransfer(1);
if (EZTwain.BeginMultipageFile(filename) == 0) {
for (j = 1; j <= N; j++) {
// If you can't get a Window handle, use IntPtr.Zero:
hdib = EZTwain.Acquire(this.Handle);
if (hdib == IntPtr.Zero) {
break;
}
// <your image processing here>
EZTwain.DibWritePage(hdib);
EZTwain.DIB_Free(hdib);
}
EZTwain.EndMultipageFile();
}
EZTwain.CloseSource();
}
if(EZTwain.LastErrorCode() != 0) {
EZTwain.ReportLastError("Unable to scan.");
}
string nodeId="";
Document doc=null;
try {
doc = imageStore.Import(filename, GetCurrentCategory());
}
catch(Exception ex) {
MessageBox.Show(Lan.g(this, "Unable to copy file, May be in use: ") + ex.Message + ": " + filename);
return;
}
FillDocList(false);
SelectTreeNode(GetNodeById(MakeIdentifier(doc.DocNum.ToString(),"0")));
FormDocInfo FormD=new FormDocInfo(PatCur,doc,GetCurrentFolderName(TreeDocuments.SelectedNode));
FormD.ShowDialog();//some of the fields might get changed, but not the filename
if(FormD.DialogResult!=DialogResult.OK){
DeleteSelection(false);
}
else{
nodeId=MakeIdentifier(doc.DocNum.ToString(),"0");
}
//Reselect the last successfully added node when necessary.
if(doc!=null && MakeIdentifier(doc.DocNum.ToString(),"0")!=nodeId) {
SelectTreeNode(GetNodeById(MakeIdentifier(doc.DocNum.ToString(),"0")));
}
FillDocList(true);
}
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
Re: MultiPage Scanning tweak...
was this ever completed? for multipage scanning?
- jordansparks
- Site Admin
- Posts: 5744
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Re: MultiPage Scanning tweak...
The code is obviously mostly there. But we can't just drop it in. It's going to take some work.
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com
- Hersheydmd
- Posts: 700
- Joined: Sun May 03, 2009 9:12 pm
Re: MultiPage Scanning tweak...
I found this thread from 2007 and I am wondering whatever happened with this? Did it ever work out? I want to shred my paper charts after scanning them into the opendental images folder. Saving them as individual single page .jpeg's is not a realistic option. Multipage .pdf's would make much more sense.
Robert M Hersh DMD, FAGD
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429
Univ. of Penn 1982
Brooklyn, NY 11234
https://www.facebook.com/pages/Robert-M ... 1471599429
- jordansparks
- Site Admin
- Posts: 5744
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Re: MultiPage Scanning tweak...
It's totally a time issue for us. I'm right in the middle of a huge complicated overhaul of the insurance benefit calculations. I've been staring at thousands of lines of math for weeks. One thing has to get finished before moving on to the next. And when deciding what to do next, it will largely be determined by the votes in the feature request system.
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
Re: MultiPage Scanning tweak...
I need to test this code out... I am buying a new all in one soon.. My scanner broke awhile back and I have just been using the neighbors if I need to scan which I do probably once a year...
Justin Shafer
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
Re: MultiPage Scanning tweak...
I did some reading in the eztwain manual and it says that most webcams will bomb if they have the resolution set in the twain commands.... Here are the commands from the wizard for webcam, single image import only... If I had a webcam I could test this better... or an IOC....
System.IntPtr hdib;
EZTwain.SetHideUI(false);
if (EZTwain.OpenDefaultSource()) {
EZTwain.SetXferCount(1);
// If you can't get a Window handle, use IntPtr.Zero:
hdib = EZTwain.Acquire(this.Handle);
if (hdib!=IntPtr.Zero) {
// <your image processing here>
EZTwain.DIB_Free(hdib);
}
}
if (EZTwain.LastErrorCode()!=0) {
EZTwain.ReportLastError("Unable to scan.");
}
System.IntPtr hdib;
EZTwain.SetHideUI(false);
if (EZTwain.OpenDefaultSource()) {
EZTwain.SetXferCount(1);
// If you can't get a Window handle, use IntPtr.Zero:
hdib = EZTwain.Acquire(this.Handle);
if (hdib!=IntPtr.Zero) {
// <your image processing here>
EZTwain.DIB_Free(hdib);
}
}
if (EZTwain.LastErrorCode()!=0) {
EZTwain.ReportLastError("Unable to scan.");
}
Justin Shafer
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
Re: MultiPage Scanning tweak...
Perhaps the dialog to choose the device would help...
// Display TWAIN Select Source dialog
EZTwain.SelectImageSource(IntPtr.Zero);
// Display TWAIN Select Source dialog
EZTwain.SelectImageSource(IntPtr.Zero);
Justin Shafer
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
- Justin Shafer
- Posts: 596
- Joined: Sat Jul 28, 2007 7:34 pm
- Location: Fort Worth, TX.
Re: MultiPage Scanning tweak...
I still havent bought that scanner. I should break down and buy one but I go to so many dental offices that have and I rarely need to use a scanner. Anyways... That code did work at that one office... But I never tried the modified code. I would like to test this more, as I am willing to bet eztwain could be with us for awhile? Stay away from Vintasoft... At least thats been my experience so far. The hard part is finding a library that works well with the majority of scanners. As I know a PMS that recently switched scannning libraries and now some offices really need to buy new scanners for it to work reliably without rebooting something.
Can I still try that code if I wanted to.. The modified one.. I guess I can try and find out. Just for fun. After I get my imaginary scanner. Would like to buy an FI-5110C, but I dont really need it.. But I could test it with an office nearby. Probably get a brother of an hp....
It looks like you guys switched to Ez-Twain Pro instead of Classic so that is cool...
Can I still try that code if I wanted to.. The modified one.. I guess I can try and find out. Just for fun. After I get my imaginary scanner. Would like to buy an FI-5110C, but I dont really need it.. But I could test it with an office nearby. Probably get a brother of an hp....
It looks like you guys switched to Ez-Twain Pro instead of Classic so that is cool...
Justin Shafer
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
Onsite Dental Systems
817-909-4222
justin@onsitedentalsystems.com
http://www.onsitedentalsystems.com
http://iocsnapshot.com
http://justinshafer.blogspot.com
Re: MultiPage Scanning tweak...
I know this is an old thread but is multipage scanning now officially supported or must one apply the tweak. If tweaking is still needed can some kind soul publish the latest version of the tweak and a brief how-to? Also could someone confirm that the tweak works and is stable with the Epson WorkForce Pro GT-S50? I ask because the office loves the Fujitsu S1500 and needs a second one. But in light of this tweak (feature?) Epson might be the way to go.
- jordansparks
- Site Admin
- Posts: 5744
- Joined: Sun Jun 17, 2007 3:59 pm
- Location: Salem, Oregon
- Contact:
Re: MultiPage Scanning tweak...
This is an ordinary feature request that we have not yet implemented. Nobody is going to take the time to "tweak" anything.
Jordan Sparks, DMD
http://www.opendental.com
http://www.opendental.com