Perl读取mathtype方程

时间:2016-12-20 02:38:29

标签: perl

我使用Perl读取包含Mathtype方程的word文档,然后将其打印到txt文件。它用“SOH”字符取代每个euation。如何将方程式从MathType转换为tex或者乳胶,如:

$y=\frac{2-x}{x-1} $ 

这是我的代码:

#!perl
use warnings;
use strict;
use Win32::OLE 'CP_UTF8';
$Win32::OLE::CP = CP_UTF8;
binmode STDOUT, 'encoding(CP932)';

my $document_name = 'C:\\Strawberry\\tam_dev\\input\\deso7.doc';
open (my $fh1, '>:encoding(UTF-8)', 'C:\\Strawberry\\tam_dev\\output\\deso7.txt');
my $word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application','Quit') or die Win32::OLE->LastError();
$word->{visible} = 1;
my $document = $word->Documents->Open($document_name) or die Win32::OLE->LastError();
my $paragraphs = $document->Paragraphs ();
my $n_paragraphs = $paragraphs->Count ();
for my $p (1..$n_paragraphs) {
    my $paragraph = $paragraphs->Item ($p);
    print $fh1 $paragraph->Range->Text ();
}

1 个答案:

答案 0 :(得分:0)

一个开始的地方似乎是MathType SDK:http://www.dessci.com/en/reference/sdk/default.htm