J
Jen Cody
I am developing a C# app. that is using MODI to generate
TIFs. The C# app. uses the native print routine from
various other apps. (such as Word, Excel, etc) to print to
MODI which has been set as the default printer. After the
TIF has been generated text is extracted and saved to
file. There are 2 major issues with the C# app. as it
currently stands:
1) I cannot find a programmatic way to specify the
output file name when the print actually occurs. The file
name is being specified by finding the location of the
textbox on the pop-up window, entering the new text and
then registering mouse up and mouse down events on the
button. I would like to find a way to programmatically
specify the output name, or is there a way to
programmatically import files into MODI and then save them
as TIFs?
2) When I process the TIFs to extract the text the
files become locked by some process and I am unable to do
anything with them after that point (move them, delete,
etc) until after I've closed my app. I am using the MODI
2003 Object Model to process the files using the following:
private string ExtractText()
{
StringBuilder sb = new StringBuilder();
int currRegion=0;
int currBottom = 0;
bool newLine = false;
string space = " ";
foreach (MODI.Image image in
document.Images)
{
try
{
foreach (MODI.Word word in
image.Layout.Words)
{
foreach (MODI.MiRect
rect in word.Rects)
{
if(rect.Bottom !
= currBottom)
{
currBottom
= rect.Bottom;
newLine =
true;
sb.Append
(Environment.NewLine);
}
}
if(word.RegionId !=
currRegion)
{
if(!newLine)
sb.Append
("\t");
newLine = false;
currRegion =
word.RegionId;
}
sb.Append(word.Text);
sb.Append(space);
}
}
catch(Exception err)
{}
}
if(sb.Length > 0)
return sb.ToString();
else
return space;
}
When I am finished processing the TIF the following code
gets called, yet I still receive error messages later on
telling me the file is in use by another application.
public void CleanUp()
{
document.Close(false);
try
{
document = null;
}
catch()
{}
}
Can someone please tell me how to release the file?
Thanks!
TIFs. The C# app. uses the native print routine from
various other apps. (such as Word, Excel, etc) to print to
MODI which has been set as the default printer. After the
TIF has been generated text is extracted and saved to
file. There are 2 major issues with the C# app. as it
currently stands:
1) I cannot find a programmatic way to specify the
output file name when the print actually occurs. The file
name is being specified by finding the location of the
textbox on the pop-up window, entering the new text and
then registering mouse up and mouse down events on the
button. I would like to find a way to programmatically
specify the output name, or is there a way to
programmatically import files into MODI and then save them
as TIFs?
2) When I process the TIFs to extract the text the
files become locked by some process and I am unable to do
anything with them after that point (move them, delete,
etc) until after I've closed my app. I am using the MODI
2003 Object Model to process the files using the following:
private string ExtractText()
{
StringBuilder sb = new StringBuilder();
int currRegion=0;
int currBottom = 0;
bool newLine = false;
string space = " ";
foreach (MODI.Image image in
document.Images)
{
try
{
foreach (MODI.Word word in
image.Layout.Words)
{
foreach (MODI.MiRect
rect in word.Rects)
{
if(rect.Bottom !
= currBottom)
{
currBottom
= rect.Bottom;
newLine =
true;
sb.Append
(Environment.NewLine);
}
}
if(word.RegionId !=
currRegion)
{
if(!newLine)
sb.Append
("\t");
newLine = false;
currRegion =
word.RegionId;
}
sb.Append(word.Text);
sb.Append(space);
}
}
catch(Exception err)
{}
}
if(sb.Length > 0)
return sb.ToString();
else
return space;
}
When I am finished processing the TIF the following code
gets called, yet I still receive error messages later on
telling me the file is in use by another application.
public void CleanUp()
{
document.Close(false);
try
{
document = null;
}
catch()
{}
}
Can someone please tell me how to release the file?
Thanks!