BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use microsoft document image writer activeX in Delphi

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Bear
Guest





PostPosted: Fri Oct 27, 2006 6:22 pm    Post subject: How to use microsoft document image writer activeX in Delphi Reply with quote



Hi ,

microsoft document image writer activeX is a good ActiveX, it could OCR text
or Save file to TIFF.
I imported it to Delphi, but failed to make it work, My Code is as blow:

procedure TForm1.Button3Click(Sender: TObject);
var Doc : OleVariant;
begin
try
Doc := CreateOleObject('MODI.Document' );
Doc.Create('D:\Test\Word.tif');
Doc.SaveAs('D:\Test\Word_MODI.tif',miFILE_FORMAT_TIFF,miCOMP_LEVEL_MEDIUM
);

except
ShowMessage('Failed to Call MODI.Document!');
Exit;
end;
Doc := unAssigned;
end;



When i run the code, the Delphi IDE always jump to CPU view at
"Doc.Create('D:\Test\Word.tif');"
Then show "'Failed to Call MODI.Document!".

Any suggestion?


Bear
Back to top
Warrick Wilson
Guest





PostPosted: Fri Oct 27, 2006 10:34 pm    Post subject: Re: How to use microsoft document image writer activeX in De Reply with quote



"Bear" <bear (AT) nobody (DOT) com> wrote in message
news:45420837 (AT) newsgroups (DOT) borland.com...
Quote:
Hi ,

microsoft document image writer activeX is a good ActiveX, it could OCR
text or Save file to TIFF.
I imported it to Delphi, but failed to make it work, My Code is as blow:

procedure TForm1.Button3Click(Sender: TObject);
var Doc : OleVariant;
begin
try
Doc := CreateOleObject('MODI.Document' );
Doc.Create('D:\Test\Word.tif');

Doc.SaveAs('D:\Test\Word_MODI.tif',miFILE_FORMAT_TIFF,miCOMP_LEVEL_MEDIUM
);

except
ShowMessage('Failed to Call MODI.Document!');
Exit;
end;
Doc := unAssigned;
end;



When i run the code, the Delphi IDE always jump to CPU view at
"Doc.Create('D:\Test\Word.tif');"
Then show "'Failed to Call MODI.Document!".

Any suggestion?



Are you initializing the ActiveX/OLE stuff with CoInitialize or
CoInitializeEx? That may be part of the problem if you're not. Maybe. I've
been burned by this in the past.
Back to top
Bear
Guest





PostPosted: Sat Oct 28, 2006 7:56 am    Post subject: Re: How to use microsoft document image writer activeX in De Reply with quote



Yes, I did.

I tried 3 times:

OleInitialize(nil);

CoInitialize(nil);

CoInitializeEx (nil, COINIT_APARTMENTTHREADED );

The same result. The call stack show it is a DispCallError.

Bear

"Warrick Wilson" <warrickw (AT) mercuryonline (DOT) com> 写入消息新闻:45424321$1 (AT) newsgroups (DOT) borland.com...
Quote:
"Bear" <bear (AT) nobody (DOT) com> wrote in message
news:45420837 (AT) newsgroups (DOT) borland.com...
Hi ,

microsoft document image writer activeX is a good ActiveX, it could OCR
text or Save file to TIFF.
I imported it to Delphi, but failed to make it work, My Code is as blow:

procedure TForm1.Button3Click(Sender: TObject);
var Doc : OleVariant;
begin
try
Doc := CreateOleObject('MODI.Document' );
Doc.Create('D:\Test\Word.tif');


oc.SaveAs('D:\Test\Word_MODI.tif',miFILE_FORMAT_TIFF,miCOMP_LEVEL_MEDIUM
);

except
ShowMessage('Failed to Call MODI.Document!');
Exit;
end;
Doc := unAssigned;
end;



When i run the code, the Delphi IDE always jump to CPU view at
"Doc.Create('D:\Test\Word.tif');"
Then show "'Failed to Call MODI.Document!".

Any suggestion?



Are you initializing the ActiveX/OLE stuff with CoInitialize or
CoInitializeEx? That may be part of the problem if you're not. Maybe. I've
been burned by this in the past.
Back to top
Nils Haeck
Guest





PostPosted: Sun Oct 29, 2006 6:09 pm    Post subject: Re: How to use microsoft document image writer activeX in De Reply with quote

Normally "Create" is reserved for the constructor. It looks fishy to call
create with a new document name, after it is already created with
CreateOleObject. Isn't there a method called "New" or something?

Calling the constructor on an already initialized object can never be good.

Nils
Back to top
Bear
Guest





PostPosted: Mon Oct 30, 2006 9:11 am    Post subject: OK Now Re: How to use microsoft document image writer activ Reply with quote

Added Doc.Create('') first to accept the first Exceptioin.


procedure TForm1.Button3Click(Sender: TObject);
var Doc : OleVariant;
begin
try
Doc := CreateOleObject('MODI.Document' );
try
Doc.Create('');
except
;
end;

Doc.Create('D:\Test\Word.tif');
Doc.SaveAs('D:\Test\Word_MODI.tif',miFILE_FORMAT_TIFF,miCOMP_LEVEL_MEDIUM
);

except
ShowMessage('Failed to Call MODI.Document!');
Exit;
end;

Doc := unAssigned;
end;



Bear

"Bear" <bear (AT) nobody (DOT) com> 写入消息新闻:45420837 (AT) newsgroups (DOT) borland.com...
Quote:
Hi ,

microsoft document image writer activeX is a good ActiveX, it could OCR
text or Save file to TIFF.
I imported it to Delphi, but failed to make it work, My Code is as blow:

procedure TForm1.Button3Click(Sender: TObject);
var Doc : OleVariant;
begin
try
Doc := CreateOleObject('MODI.Document' );
Doc.Create('D:\Test\Word.tif');

Doc.SaveAs('D:\Test\Word_MODI.tif',miFILE_FORMAT_TIFF,miCOMP_LEVEL_MEDIUM
);

except
ShowMessage('Failed to Call MODI.Document!');
Exit;
end;
Doc := unAssigned;
end;



When i run the code, the Delphi IDE always jump to CPU view at
"Doc.Create('D:\Test\Word.tif');"
Then show "'Failed to Call MODI.Document!".

Any suggestion?


Bear
Back to top
Bear
Guest





PostPosted: Mon Oct 30, 2006 9:11 am    Post subject: Re: How to use microsoft document image writer activeX in De Reply with quote

Create is a method in IDocument !.

Bear

// *********************************************************************//
// Interface: IDocument
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {D4073843-A58A-469A-A8E2-CFF3FF77EE4E}
// *********************************************************************//
IDocument = interface(IDispatch)
['{D4073843-A58A-469A-A8E2-CFF3FF77EE4E}']
procedure Save; safecall;
procedure Close(SaveChanges: WordBool); safecall;
procedure SaveAs(const FileName: WideString; FileFormat: MiFILE_FORMAT;
CompLevel: MiCOMP_LEVEL); safecall;
function Get_Images: IImages; safecall;
function Get_BuiltInDocumentProperties: IDispatch; safecall;
function Get_CustomDocumentProperties: IDispatch; safecall;

procedure Create(const FileOpen: WideString); safecall;

function Get_Dirty: WordBool; safecall;
procedure OCR(LangId: MiLANGUAGES; OCROrientImage: WordBool;
OCRStraightenImage: WordBool); safecall;
procedure PrintOut(From: Integer; To_: Integer; Copies: Integer; const
PrinterName: WideString;
const PrintToFileName: WideString; PrintAnnotation:
WordBool;
FitMode: MiPRINT_FITMODES); safecall;
property Images: IImages read Get_Images;
property BuiltInDocumentProperties: IDispatch read
Get_BuiltInDocumentProperties;
property CustomDocumentProperties: IDispatch read
Get_CustomDocumentProperties;
property Dirty: WordBool read Get_Dirty;
end;



"Nils Haeck" <bla (AT) bla (DOT) com> 写入消息新闻:454498f4 (AT) newsgroups (DOT) borland.com...
Quote:
Normally "Create" is reserved for the constructor. It looks fishy to call
create with a new document name, after it is already created with
CreateOleObject. Isn't there a method called "New" or something?

Calling the constructor on an already initialized object can never be
good.

Nils

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.