Book a Demo

Author Topic: Doc-Generation: call JScript from template and have sth inserted in PDF [solved]  (Read 5132 times)

Shegit Brahm

  • EA User
  • **
  • Posts: 98
  • Karma: +1/-0
    • View Profile
Hi there,

I have following situation:
I'd like to use as much onboard mechanics as possible to create a customized PDF of a package's content.

EA has build in the way: F8 on a package and selecting some templates (front, toc, main) and set some options and ... voila, a PDF is generated.

What I think I don't want: write my own addin. Because the more "wysiwyg" is visible via template and the less code, the better for maintenance by other people (I suppose).

The tricky part already started that the achieved PDF is that individual, that I start with a template, go over to a fragment with TemplateSelector and run specific fragments.

In my attempts I figured out that a TemplateSelector can only decide by element type and a sql query misses something like "if then else". Because I would need for each table a fragment - otherwise the tables got mixed up.

So I'd like to point the template to a JScript-fragment which should point to a fragment again. (JScript instead VBScript by flip of a coin)
Because I want to decide e.g. on element's colour which I cannot so far by using a template selector.

My questions:
- Is that possible, to go from a template to JScript then to a fragment and having everything inside the PDF which is created by the template in the first place?
- Where can I read about it?

I'm able to pass the object id and package id from template to JScript  - main(#OBJECTID#, #PACKAGEID#) - and create a separate document (Class EA.DocumentGenerator).
I just tried to read through EA pages and examples and don't know which keywords I need to look for.

Thanks, Shegit
« Last Edit: January 17, 2018, 01:16:46 am by Shegit Brahm »

Nizam

  • Prolab Moderator
  • EA User
  • *
  • Posts: 320
  • Karma: +15/-2
  • Model Sharing - Simplified
    • View Profile
    • Professional Model Collaboration
Re: Doc-Generation: call JScript from template and have sth inserted in PDF
« Reply #1 on: January 16, 2018, 04:23:11 am »
I think document script option in the recent versions of EA is what you'll need. You cann call a script from this fragment,  which can call other templates as per the script logic.

This link could give an idea http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/model_publishing/custom_query_fragments.html

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Doc-Generation: call JScript from template and have sth inserted in PDF
« Reply #2 on: January 16, 2018, 06:01:44 am »
Shegit,

I use virtual documents for that purpose.
And I use a script to create the virtual document with all it's sections. Often a section only reports on a single (part of) an element, so I can control very precisely what will be generated, with which templates, and in which order.

The advantage is that you have an inbetween step where a user can still change something (like choose another template for a section, change the order, remove a section, etc..)

I wrote an article about this: https://bellekens.com/2015/11/12/tutorial-generate-complex-documents-from-enterprise-architect-with-a-two-step-semi-automated-approach/

Geert

Nabil

  • EA User
  • **
  • Posts: 149
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Doc-Generation: call JScript from template and have sth inserted in PDF
« Reply #3 on: January 16, 2018, 05:01:58 pm »
Hello Shegit,

I have an example model for how document script works in EA.
You can download it from this link

Cheers
Nabil
« Last Edit: January 16, 2018, 08:48:35 pm by Nabil »
Nabil

Shegit Brahm

  • EA User
  • **
  • Posts: 98
  • Karma: +1/-0
    • View Profile
Re: Doc-Generation: call JScript from template and have sth inserted in PDF
« Reply #4 on: January 17, 2018, 01:16:20 am »
Hi you three,

thank you very much for your suggestions and links.

I will take a look at it and if I have specific questions, I will post them in new topics :-)

@Nizam: I read that page from Sparx, I just didn't manage to have the script-called fragment to insert anything inside PDF

@Geert: I avoided RTF until now, so I will try to forget RTF experiences from outside EA and start over again.

@Nabil: thanks for providing a full eap, will take a look.

Shegit