STM publishing: tools, technologies and change A WordPress site for STM Publishing

9Feb/12Off

LuaCOM: connecting LuaTeX to Windows automation

Posted by Graham Douglas

Introduction

The Windows operating system provides a technology called COM, which stands for Component Object Model. In essence, it provides a way for software components and applications to "talk to each other". That's a gross oversimplification but it gives the general idea. It's now an old technology but nevertheless it is still very powerful; over the years I've used it quite extensively for automating various publishing/production tasks. In those days it was with Perl using a module called Win32::OLE.

Of course, applications have to be written to support COM so you can think of COM-aware applications as offering a "set of services" that you can call --- many applications provide the ability to call those services from scripting languages which have support for COM (via modules/plugins etc), such as Perl, Ruby and, of course, Lua via LuaCOM. A combination of COM-aware applications and scripting languages with COM support provides a very flexible way to "glue together" all sorts of different applications to create novel automated workflows/processes.

Using COM from within scripting languages is fairly straightforward but under the surface COM is, to me anyway, a complex beast indeed. The best low-level COM programming tutorials I have ever read are published on codeproject.com, written by Michael Dunn. Here's one such tutorial Introduction to COM - What It Is and How to Use It.

LuaCOM

LuaCOM lets you use COM in your Lua scripts, i.e., it is a binding to COM. I don't know if there are freely available builds of the latest version (probably with Windows distributions of Lua), but you can download and compile the latest version from Github.

LuaCOM is a DLL (Dynamic Link Library) that you load using the standard "require" feature of Lua. For example, to start Microsoft Word from within your Lua code, using LuaCOM, you would do something like this:

com = require("luacom")
-- should be CreateObject not GetObject!
Word =com.CreateObject("Word.Application")
Word.Visible=1
doc = Word.Documents:Open("g:/x.docx")

Naturally, the Microsoft Office applications have very extensive support for COM and offer a huge number of functions that you can call should you wish to automate a workflow process via COM from within Lua. For example, you can access all the native equation objects within a Word document (read, write, create and convert equations...). If you have watched this video and wondered how I got LuaTeX and Word to talk to each other, now you know: LuaCOM provided the glue.

13Oct/11Off

Uploading graphics from Word 2007 directly to my blog

Posted by Graham Douglas

Carrying on the experiments. How well does Word render native objects to blog posts? Here are some Word charts and graphics. The images you see have been rendered by Word and then uploaded. I've not edited or altered them in any way: what you see is exactly as it was uploaded. Fairly reasonable results I'd say. Of course, SVG would be nicer but maybe one day : -~)

12Oct/11Off

Uploading tables from Word 2007 directly to my blog

Posted by Graham Douglas

Word 2007 and beyond can upload content directly to blogs. So, I was curious to see how well Word can post tables to my blog.  Results below, untouched and exactly as they appeared after upload.

The actual data uploaded by Word is amazingly clean/simple! I thought it would be horribly complicated but I was delighted to be wrong! Clearly, the presentation you see is affected by this site's WordPress theme CSS. Which I admit does not look that good.  In the WordPress content editor, the tables look great and are easy to edit. See screenshot below.

As a way to write offline and then post to your blog, it could have its uses.

Screenshot of the behind-the-blog content editor.

Raw and untouched tables: a selection from Word's "Quick Tables" facility. Compare with the content editor view above.

City or Town

Point A

Point B

Point C

Point D

Point E

Point A

Point B

87

Point C

64

56

Point D

37

32

91

Point E

93

35

54

43

ITEM NEEDED
Books 1
Magazines 3
Notebooks 1
Paper pads 1
Pens 3
Pencils 2
Highlighter 2 colors
Scissors 1 pair

Enrollment in local colleges, 2005

College New students Graduating students Change
Undergraduate
Cedar University 110 103 +7
Elm College 223 214 +9
Maple Academy 197 120 +77
Pine College 134 121 +13
Oak Institute 202 210 -8
Graduate
Cedar University 24 20 +4
Elm College 43 53 -10
Maple Academy 3 11 -8
Pine College 9 4 +5
Oak Institute 53 52 +1
Total 998 908 90

Source: Fictitious data, for illustration purposes only