Book a Demo

Author Topic: Cannot create numbered headings with Document Generator.  (Read 3617 times)

jepessen

  • EA User
  • **
  • Posts: 106
  • Karma: +1/-1
    • View Profile
Cannot create numbered headings with Document Generator.
« on: November 20, 2020, 09:30:32 pm »
This is my test script:

Code: [Select]
!INC Local Scripts.EAConstants-JScript

 
function main()
{
var generator = Repository.CreateDocumentGenerator();
generator.SetStyleSheetDocument("Numbered Headings");
generator.NewDocument("");
generator.InsertText("This is Heading 1\n", "Heading 1");
generator.InsertText("This is Heading 2\n", "Heading 2");
generator.InsertText("This is Heading 3\n", "Heading 3");
generator.InsertText("This is Heading 4\n", "Heading 4");
generator.InsertText("This is Heading 5\n", "Heading 5");
generator.saveDocument("d:/dummy.docx", 3);
}

main();

As you can see, I'm setting the "Numbered Headings" stylesheet, Then I've created some headings.

In the image you can see the result. As you can see headings are not numbered, even if I've set the Numbered Headings stylesheet before creating the new document.

How can I create numbered headings with the DocumentGenerator with InsertText?


Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Cannot create numbered headings with Document Generator.
« Reply #1 on: December 01, 2020, 03:13:33 am »
Numbered headings in Word are hard, and fiddly. We even find this with eaDocX, which has the luxury (?) of talking directly to the Word API, and even then there is much Dark Magic to make it work correctly.
If you're tageting Word, I suggest having a look at eaDocX (well, I would, wouldn't I...). Because we ONLY target Word, the integration is much tighter (internal hyperlinks, word table styles, real-time glossary, table numbers etc etc).
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com