Using Microsoft Word to create smart contracts

This article is being written…

How a Microsoft Word document is transformed and displayed as a Smart Contract
How a Microsoft Word document is transformed and displayed as a Smart Contract

#new, #features, #contracts, #word, #microsoft, #neuro-foundry


Utility for converting Microsoft Word documents to Markdown

A new utility called WordToMarkdown has been published helping users to convert Microsoft Word documents (saved in .docx file format) to Markdown. The utility can be used either on the command-line to automate conversions (for instance, if you want to keep a web-site current with content written in Word documents), or via a Windows GUI. The utility can convert single documents, or convert batches of documents identified using one or more wildcards (*).

Download

You can download and install the utility from this link:
https://lab.tagroot.io/Downloads/WordToMarkdown/setup.exe

Once the utility has been installed, you will find it in the Start Menu, by typing WordToMarkdown.

Repository

Source code is available in the MicrosoftInterop repository on GitHub. You can build the utility in Visual Studio, by building the WordToMarkdown project in the solution.

GUI

The GUI of the WordToMarkdown utility is a simple window with the following input controls:

  • An input file input. Enter the name of the Word file here. You can use wildcards (*) to identify a batch of files to process. Press the ... button to select a file using a file open dialog.

  • An output file input. Enter the name of the Markdown file here. You can also enter the name of a folder. In such a case, the output file will have the same file name as the input file, except having the file extension replaced with .md. Press the ... button to select a file using a file open dialog. If using wildcards (*) in the file name, the number of wildcards should match the number of wildcards in the input file name.

  • A recursive checkbox. If checked, and using wildcards, the utility will scann the input folder, and all subfolders for input files matching the pattern provided in the input file name field.

  • Press the Convert button to start the conversion process. A message at the end will inform you about the results of the conversion.

WordToMarkdown GUI
WordToMarkdown GUI

Command-Line

You can execute the utility using Command-Line options. This allows you to automate conversions, without the need to use the Windows GUI. If you’ve built the utility using Visual Studio, you will find the executable in the build output folder. If you’ve installed the utility you can find the installation location in the following way:

  1. Start the utility
  2. Open the Task Manager, and find the utility in the processes page.
  3. Right-click on the process, and press Properties.
  4. Under Location on the first tab, you will find the location where the application has been installed.

Note: Since the installer is a Click-Once installer, the installation location may look strange.

To find the command-line options of the utility, open a terminal window, and go to the location where the utility is installed using the cd command. Type:

WordToMarkdown -?

This will list the command-line options:

Command-line options
Command-line options

Note: Using the command-line options method, you can add custom Markdown meta-data headers to the converted files. This may be useful if generating a web site with content from the Word documents. See the Markdown Meta-data documentation for more information about meta-data tags.

#utility, #word, #microsoft, #markdown, #new, #repository


Microsoft Interoperability API (Excel)

The free API package for interoperability with Microsoft products on neurons has been extended, to now support interoperability with Microsoft Excel documents also (saved using Open XML SDK, i.e. .xlsx documents). Conversion of Spreadsheets is also supported, to Script. This can be used for processing the information in the Spreadsheets, using scrfipt operations, etc. The Mictosoft Interoperability package is an optional component that can be installed by the neuron operator. The API is protected, and requires either a login (using user accounts defined by the Admin-interface; no special privileges), or a JWT token issued by the neuron (available to clients connected via XMPP, for instance), or being logged in through a web session. The API cannot be accessed anonymously.

Some more information
Package TAG.MicrosoftInterop.package
Installation key Y/0hf+O003/pMh6CDnQTowb3DMJj3X28Xu0H0/bOPsIdGo+XOGY2kWsEyxkpKMSNdAOjSGDlxUIA00c066163c7125123382bdd308a2ad35
More information https://github.com/Trust-Anchor-Group/MicrosoftInterop

Script Prompt

Once the package has been properly installed, it will insert itself into the Script Prompt on the Neuron®. It introduces an Excel button that can be used to open an INPUT field that allows you to upload an Excel document to the server, and convert it to Script, on the page. This way, you can experiment with the conversion capabilities provided. If you want to have documents for testing purposes, the repository contains a set of testing documents.

Converting MultipleSheets.xlsx to Script
Converting MultipleSheets.xlsx to Script

Internet Content Decoder

The package contains an Internet Content decoder for MS Excel documents. This means you can build your own web services, and similar tools, that receive Excel documents as content, and they will be automatically decoded. No automatic conversion to script is provided, as the script is supposed to be converted on the server, and not provided to the client, by default. You can convert the received Excel document using the static ExcelUtilities class on the server, or via the conversion API resource, if you request the script on the client.

Formatting Support

Microsoft Word supports a very rich set of features for formatting content in their documents. Markdown on the other hand, is not designed for creating formatted content in the same way, so a 1-to-1 conversion is not possible. But basic formatting constructs can be converted successfully. The following lists should give you an idea of what is supported and not.

What is exported?

As spreadsheets are exported to script, for processing purposes, formatting and Excel-specific formulas are not exported. Only values, and data types (such as the difference between strings, normalized (reused) strings, numbers, dates, times, etc.) are exported. Each sheet is exported as a Matrix, and a collection of sheets is exported as an object, where the tab names are used as property names, and the corresponding matrices as property values.

Logging of unrecognized elements

If converting an Excel document that contains elements the package library does not understand, information about these items will be logged to the event log. You can use this information to extend support to such items in the repository.

API Endpoint

API interface for the Excel -> Script conversion is very simple. You execute a POST to the /MicrosoftInterop/ExcelToScript resource on the Neuron® where the package is installed. The contents of the POST is the actual Excel document. The response will be Script, as text.

#api, #features, #new, #excel, #script, #microsoft


Microsoft Interoperability API (Word)

A free API package for interoperability with Microsoft products is now available on neurons. The first version allows you to convert Microsoft Word documents (saved using Open XML SDK, i.e. .docx documents) to Markdown. This can be used for presentation purposes, or for the purposes of creating smart contracts, etc. It is an optional component that can be installed by the neuron operator. The API is protected, and requires either a login (using user accounts defined by the Admin-interface; no special privileges), or a JWT token issued by the neuron (available to clients connected via XMPP, for instance), or being logged in through a web session. The API cannot be accessed anonymously.

Some more information
Package TAG.MicrosoftInterop.package
Installation key Y/0hf+O003/pMh6CDnQTowb3DMJj3X28Xu0H0/bOPsIdGo+XOGY2kWsEyxkpKMSNdAOjSGDlxUIA00c066163c7125123382bdd308a2ad35
More information https://github.com/Trust-Anchor-Group/MicrosoftInterop

Markdown Lab

Once the package has been properly installed, it will insert itself into the Markdown Lab on the Neuron®. It introduces an INPUT field that allows you to upload a Word document to the server, and convert it to Markdown, on the page. This way, you can experiment with the conversion capabilities provided. If you want to have documents for testing purposes, the repository contains a set of testing documents.

Converting SimpleText.docx to Markdown
Converting SimpleText.docx to Markdown

Internet Content Decoder and Converter

The package contains an Internet Content decoder for MS Word documents. This means you can build your own web services, and similar tools, that receive Word documents as content, and they will be automatically decoded. There’s also an Internet Content converted from Word to Markdown that can be used to publish Word documents directly on the site. These documents will be automatically converted to Markdown, and from Markdown to any other accepted format (like HTML), if the request indicates that the client only accepts HTML, for instance. This allows you to publish content directly using Word documents, without the need to converting them manually first.

Formatting Support

Microsoft Word supports a very rich set of features for formatting content in their documents. Markdown on the other hand, is not designed for creating formatted content in the same way, so a 1-to-1 conversion is not possible. But basic formatting constructs can be converted successfully. The following lists should give you an idea of what is supported and not.

Supported

  • Sections
  • Multiple columns
  • Paragraphs and justifications (Left, Right, Center, Justify)
  • Simple formats, such as Bold, Italic, Underline, Strike Tough, Superscript, Subscript, Insert, Delete, inline code
  • Block code
  • Horizontal separators
  • Some fields and form input controls
  • Tables, column spans
  • Lists (Bullet-point lists, numbered lists, mixed lists)
  • Table of contents
  • Images & Figures
  • Captions
  • Frame contents
  • Footnotes
  • Endnotes

Not Supported (examples)

  • Languages
  • Positioning
  • Colors
  • Fonts
  • Sizes
  • Pages
  • Headers
  • Footers
  • Macros
  • Some fields and form input controls
  • Row spans in tables
  • Custom list formats.
  • Indexes, Bibliographies, etc.
  • Drawings and Shapes
  • Frame position and layout.

Logging of unrecognized elements

If converting a Word document that contains elements the package library does not understand, information about these items will be logged to the event log. You can use this information to extend support to such items in the repository.

API Endpoint

API interface for the Word -> Markdown conversion is very simple. You execute a POST to the /MicrosoftInterop/WordToMarkdown resource on the Neuron® where the package is installed. The contents of the POST is the actual Word document. The response will be Markdown.

Example code

The following Markdown snipped, with associated Javascript function call, will call the API, and convert a Word document provided via a file INPUT tag, and place it into a TEXTAREA tag on the page. This code is inserted into the Markdown Lab available to logged in users with sufficient privileges on the Neuron®:

HTML file INPUT field
HTML file INPUT field

Javascript POST
Javascript POST

#api, #markdown, #word, #microsoft, #new, #features


Posts tagged #microsoft

No more posts with the given tag could be found. You can go back to the main view by selecting Home in the menu above.