Home / eaDocX Homepage / EaDocX Help / Scripted Formatting
Scripted Formatting
eaDocX tries to give you lots of ways to format your document: inline and tables, element reports, matrix reports and Model-view based.
But sometimes, all these options aren’t enough. This may be because your document needs to conform to an existing document style, or where you’re using EA in a way which we just haven’t seen before.
This is where Scripted Formatting might help.
It allows you to create little EA Scripts which act as mini-eaDocX Generators, creating those little bits of your document which regular eaDocX can’t manage.
A warningÂ
Writing EA scripts is not for the faint-heated! It requires knowledge of both Script programming, and of the internal of EA. You don’t need to know about either of these to make the rest of eaDocX work, so including this feature goes against what eaDocX is trying to do – create quick, simple, great-looking documents. So we don’t expect many eaDocX users to use Scripted Formatting, but it should allow those users with really complicated requirements to keep using eaDocX, and stop eaDocX from getting more complicated.
Top Tip
All of the JavaScript examples below were created with a LOT of help from ChatGPT. We just explained what we wanted, and after a few tries (testing them using the Script Tester) we got what we wanted. WE strongly suggest this approach. This way, you don’t need to learn JavaScript, or be familiar with the EA API.
Setting-up Scripting
- In the Profiles tab, choose the element type/stereotype you want to print with your script
- In the eaDocX Profile Editor, find the #Format’ tab, and choose ‘Script’
- Choose the script you want from the list, and save.
Note that eaDocX scripts do not care which type of element they are applied to (unlike Model Expert validation scripts, which do). So you can use the same script for format lots of different kinds of elements.
More warnings
When eaDocX generates documents, it adds lots of formatting to things like paragraphs and tables to make them look nice. For example, to use paragraph and tables styles which are built in to your document. If you want to do the same, the out from your file needs to contain this as well, and this s not simple. Or easy to maintain.
And don’t even think about using Scripts to generate interactive documents. VERY hard. Or adding eaDocX-style hyperlinks. Very Very hard.
Some examples
To get you started, we have provided some example scripts which you can copy & paste from here. These are provided as examples only – use them at your own risk.
- Static test. This script uses hard-coded Element GUIDs, which allows you to step through the script using EA’s script debuggers. Once that is working, replace the hard-coded GUIDs with processing of the parameters wihc eaDocX will send to your script.
- Simple Table. Just shows how hard it is to even create a simple table using scripting
- Using second stereotype. eaDocX can’t format document based on a second stereotype. If that’s what you need, here’s how to do it.
- Advanced tables. Print tables-inside-tables
- Seamless formatting. Shows how to add all the extra bits to your script to make things look like eadocX-generated content