Help needed in migrating from Windows
From: Dave (daveandniki_at_ntlworld.com)
Date: 06/05/05
- Next message: John-Paul Stewart: "Re: x800 video card, x server won't start"
- Previous message: Linønut: "Re: An Open Letter To The Linux Enthusiasts."
- Next in thread: Dan Espen: "Re: Help needed in migrating from Windows"
- Reply: Dan Espen: "Re: Help needed in migrating from Windows"
- Reply: Philipp Pagel: "Re: Help needed in migrating from Windows"
- Reply: CPUFreak91: "Re: Help needed in migrating from Windows"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 05 Jun 2005 14:52:38 GMT
The code snippet below prints out a bilingual dictionary of mine into
MSWord. The dictionary entries are in an XML file that I edit with VIM. The
Perl script parses the file, processes and sorts the data and puts it in a
data structure of paragraphs composed of pieces of text with formatting
instructions (I may add more options in the future). I can also print out
plain text or html with similar routines. The Word output has the advantage
of allowing me to add page numbers and insert an introduction etc easily.
I would like to migrate this to Linux (I have XP / SuSE 9.1 dual boot on my
notebook) but am unsure of which program to replace Word with. OOo does not
seem to automate as easily. I don't know which line to go down: TeX, PDF, a
different Word processor? It would be easy to output XML and then use a
'stylesheet' to get this to output PDF for instance if there was a program
around to do this step. Any thoughts on what tools I should be considering?
Thanks,
Dave
sub word_print {
use Win32::OLE;
Win32::OLE->Option(CP => Win32::OLE::CP_UTF8());
my $word = CreateObject Win32::OLE 'Word.Application' or die $!;
$word->{'Visible'} = 1;
my $document = $word->Documents->Add;
my $selection = $word->Selection;
$selection->Font->{Name} = "Gentium";
my $i = 0;
foreach my $para (@foutput) {
$i++; last if $i == 50; # just a few for debugging
foreach (@{$para}) {
if (@{$_}[1] eq "") {
$selection->TypeText(@{$_}[0]);
}
elsif (@{$_}[1] eq "b") {
$selection->Font->{Bold} = 1;
$selection->TypeText(@{$_}[0]);
$selection->Font->{Bold} = 0;
}
elsif (@{$_}[1] eq "i") {
$selection->Font->{Italic} = 1;
$selection->TypeText(@{$_}[0]);
$selection->Font->{Italic} = 0;
}
elsif (@{$_}[1] eq "s") {
$selection->Font->{Superscript} = 1;
$selection->TypeText(@{$_}[0]);
$selection->Font->{Superscript} = 0;
}
else {
die "Unknown formatting: " . @{$_}[1];
}
}
$selection -> TypeParagraph;
}
$document->SaveAs("$outfile") or die "Could not save: " .
Win32::OLE->LastError() . "\n";
$word->Close;
}
- Next message: John-Paul Stewart: "Re: x800 video card, x server won't start"
- Previous message: Linønut: "Re: An Open Letter To The Linux Enthusiasts."
- Next in thread: Dan Espen: "Re: Help needed in migrating from Windows"
- Reply: Dan Espen: "Re: Help needed in migrating from Windows"
- Reply: Philipp Pagel: "Re: Help needed in migrating from Windows"
- Reply: CPUFreak91: "Re: Help needed in migrating from Windows"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|