Miraplacid Home Contact UsStoreDownloadsMiraplacid NewsMiraplacid ForumSearch at Miraplacid.com
Miraplacid Publisher (Image Printer Driver)Miraplacid Text Driver (Text Printer Driver)Miraplacid Data ViewerMiraplacid Form
Bookmark this pageMiraplacid PublisherMiraplacid Text DriverMiraplacid Data Viewer / Binary DOMMiraplacid Company

Miraplacid Text Driver : Extract Text from Documents

 

Miraplacid Text Driver 3.1: Scripting Manual

Scripting and Programming Support with Miraplacid Publisher Manager


Miraplacid Text Driver registers itself as an ActiveX object and could be used from any scripting and OLE-compliant software.
Using this ability, you can control the printing process directly from your script or application.

Miraplacid Text Driver Scripting Object Creation

To create component, use following constructions
  • JScript: var obj = WScript.CreateObject("Miraplacid.TextDriver");
  • VBScript: set obj = WScript.CreateObject("Miraplacid.TextDriver")
  • Visual Basic: Set obj = CreateObject("Miraplacid.TextDriver")
    To enable early binding, you have to check "mtd_core 3.1 Class Library" in "Project References" dialog and insert the following code:
    Dim obj As Miraplacid.TextDriver
    Set obj = CreateObject("Miraplacid.TextDriver")

 
How to print document from script with no user interaction? Start MTD_UI.exe, turn it to auto-save mode, then start the script.
Hint: Use /Hidden and /AutoSave command line parameters.
 
Recommended BAT file to run a script:

@echo off
rem Miraplacid Text Driver 3.1 :: BAT file
start /D"C:\Program Files\Miraplacid\TextDriver\" mtd_ui.exe /Hidden /AutoSave
CScript.exe myscript.vbs
where myscript.vbs is your script name (see sample scripts below)
Unregistered version of Miraplacid Text Driver shows registration dialog, so bat file might open the Word document before you click "Continue". Add WScript.Sleep(5000) at the beginning of your script file to synchronize it.

Appendix A: Object Miraplacid.TextDriver


Property Type Description
plugin_id long Select plug-in ("Output Style").
0 - Text with Layout
1 - XML
2 - Plain Text
charset E_CHARSET Character set
5 - UNICODE
437 - OEM American DOS
850 - OEM Latin-1 DOS
852 - OEM Eastern Europe DOS
866 - OEM Cyrillic DOS
932 - Japanese
936 - Chinese (Simplified")
949 - Korean
950 - Chinese (Traditional)"
1250 - ANSI Latin-1 Windows
1251 - ANSI Cyrillic Windows
1252 - ANSI Eastern Europe Windows
1257 - ANSI Baltic Windows
writemode E_WRITEMODE Append or Overwrite mode
0 - Overwrite
1 - Append
UNIX_EOL long (get, put) End Of Line style
0 means "Windows" EOL style (\r\n or 0x0D, 0x0A)
1 means "UNIX" EOL style (\n or 0x0A)
filename BSTR Output Filename. {{DATE}}, {TIME}}, {{IDENTITY}}, {{PAGE}} and {{JOB}} will be replaced with current date, time, some unique number, page number and print job id respectively.

Appendix B: Sample script on VBScript


'
' Miraplacid Text Driver 3.1 :: Printing from MS Word Example (VBScript)
'

set word = WScript.CreateObject("Word.Application")
word.Visible=1
word.Documents.Open("hello.doc")
word.Documents("hello.doc").Activate()

' Get active printer name
'WScript.Echo("Printer: '"+word.ActivePrinter+"'");

word.ActivePrinter="Miraplacid Text Driver on MTD"

set prn = WScript.CreateObject("Miraplacid.TextDriver")

prn.filename="c:\\worddoc.txt" ' Set Output Filename
prn.plugin_id=2 ' Set Plugin
prn.writemode=1 ' Append
prn.charset=5 ' Unicode

prn=0

' Print Word document:
word.ActiveDocument.PrintOut

' Close Word document
word.ActiveDocument.Close
word.Quit

Appendix C: Sample script on JScript


//
// Miraplacid Text Driver :: Printing from MS Word Example (JScript)
//

word = WScript.CreateObject("Word.Application");
word.Visible=1;
word.Documents.Open("hello.doc");
word.Documents("hello.doc").Activate();

// Get active printer name
//WScript.Echo("Printer: '"+word.ActivePrinter+"'");

word.ActivePrinter="Miraplacid Text Driver on MTD";

prn = WScript.CreateObject("Miraplacid.TextDriver");

prn.filename="c:\\worddoc.txt"; // Set Output Filename
prn.plugin_id=2; // Set Plugin 
prn.writemode=1; // Append
prn.charset=5;// Unicode

prn=null;

// Print Word document:
word.ActiveDocument.PrintOut();

// Close Word document
word.ActiveDocument.Close();
word.Quit();

Appendix D: Command Line:


MTD_UI.exe supports following command line parameters:
 
Parameter Description
/Hidden Hide Miraplacid Text Driver dialog. You can show it back via tray icon menu.
/AutoSave Turn Auto-Save mode on

Appendix E: PostProcessing:


It is possible to start an external application to process the result text file. Start Regedit.exe (we do it with "Run..." dialog in Start menu - just type "regedit") then open registry key

HKEY_LOCAL_MACHINE/SOFTWARE/Miraplacid/TextDriver
and add string value "Postprocessor". Specify the application you want to start.
Specified application will be started with text file name as a parameter. For example, "Postprocessor" = "Notepad" will open result text file in Notepad.
 
To start the postprocessor for each page just add {{PAGE}} to output filename. Each page will be saved to individual file. postprocessor will be called for each file. If all the pages are saved to a single file, postprocessor will be called once per document.

See also:

Copyright © 2001 - 2024 by Miraplacid.  Legal Notices