FNC WX Docx: Generating Word documents made easy!

In need of an intuitive way to generate Docx files with Delphi without having to install Microsoft® Word? TMS has you covered! With the latest release of TMS FNC WX Pack, we’ve added the new TTMSFNCWXDocx component which lets you generate Docx files on all platforms. 

We’ve added a lot of functionality to offer maximum
flexibility and allow you to customize the document requirements. 

You can add: 

  • formatted text
  • tables
  • images
  • table of contents
  • headers
  • footers
  • bookmarks
  • links
  • page numbering

Everything you’ll need to build your documents. It’s
even possible to export the document structure to a JSON template. A template
that can easily be modified and used to perform actions like mail merging.

Creating a document

The creation of the document is intuitive. you can work with predefined methods and properties to customize your document. You can see how to create a document in this video:

Building a template

Building a template is as simple as adding the fields you want to edit later and just set the ID of that field. You can later use this ID to search the document for the desired field.

Using a template

After creating a template you can use following code to generate an invoice. This is a code snippet from the advanced demo. This code loops over a dataset and creates for every customer their invoices. 


  while not Customers.Eof do
    id := Customers.FieldByName('CustNo').AsInteger;
    AsText(TMSFNCWXDocx1.FindByID('CustNo') as TTMSFNCWXDocxChild).Text := IntToStr(id);
    AsText(TMSFNCWXDocx1.FindByID('Contact') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('Contact').AsString;
    AsText(TMSFNCWXDocx1.FindByID('Company') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('Company').AsString;
    AsText(TMSFNCWXDocx1.FindByID('Phone') as TTMSFNCWXDocxChild).Text :=Customers.FieldByName('Phone').AsString;
    AsText(TMSFNCWXDocx1.FindByID('FAX') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('FAX').AsString;
    AsText(TMSFNCWXDocx1.FindByID('Addr1') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('Addr1').AsString;
    AsText(TMSFNCWXDocx1.FindByID('Addr2') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('Addr2').AsString;
    AsText(TMSFNCWXDocx1.FindByID('Zip') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('Zip').AsString;
    AsText(TMSFNCWXDocx1.FindByID('City') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('City').AsString;
    AsText(TMSFNCWXDocx1.FindByID('Country') as TTMSFNCWXDocxChild).Text := Customers.FieldByName('Country').AsString;
    t := AsTable(TMSFNCWXDocx1.FindByID('Items') as TTMSFNCWXDocxChild);
    toPay := 0;
    orders.Filtered := False;
    Orders.Filter := 'CustNo = ' + IntToStr(id);
    Orders.Filtered := true;
    while not Orders.Eof do
      tr := t.AddRow;
      tc := tr.AddCell;
      p := tc.AddParagraph;
      tc := tr.AddCell;
      p := tc.AddParagraph;
      tc := tr.AddCell;
      p := tc.AddParagraph;
      tc := tr.AddCell;
      p := tc.AddParagraph;
      tc := tr.AddCell;
      p := tc.AddParagraph;
      toPay := toPay + Orders.FieldByName('ItemTotalPrice').AsFloat;
    AsText(TMSFNCWXDocx1.FindByID('TotalToPay') as TTMSFNCWXDocxChild).Text := FloatToStr(toPay);
    TMSFNCWXDocx1.GetDocxAsFile(TPath.Combine(pth,'Invoice' + IntToStr(id) + '.docx'));

This will generate the following document on the right from the template on the left.

TMS Software Delphi  Components TMS Software Delphi  Components

Available Today!

The TTMSFNCWXDocx component is available in the latest update, available today. So go ahead and download the latest version of the TMS FNC WX Pack. The TMS FNC WX Pack is part of the FNC family, so as a reminder, below is an overview of what FNC has to offer.

TMS FNC Components can be used simultaneously on these frameworks

TMS FNC Components can be used simultaneously on these operating systems/browsers

TMS FNC Controls can be used simultaneously on these IDEs