简体   繁体   中英

Document Generation with template in Enterprise Architect with an Add-In C#

I am working on an Enterprise Architect Add-In in C# in Visual Studio Express 2013 to make documentations for a single element/elements in a package. I made a template in EA with the help of the Document Generator, where i want to write some of the element's properties on the output. Example:

package >
element >
Name: {Element.Name}... more attributes of the element
< element
< package

The problem is that when i use my Add-In to generate the document the output will be like this:

package >

Name: Random TestName

< package

between package > < package is blank, and as default the document should not contain these fields in the output, how can i make it disappear? I tried to fill between the package fields with something like {Pkg.Version}, but i only get this text in the output, not the value of it. In the Document Template Designer under Sections window if i check "Element" box it checks the "Package" box too, but if i try to uncheck the "Package" it unchecks the "Element" too - any suggestions how can i make it work? My Add-In works like this:

EA.Element element = repository.GetTreeSelectedObject();
int elementID = element.ElementID;
EA.DocumentGenerator docGen = repository.CreateDocumentGenerator();
docGen.NewDocument("");
docGen.InsertTemplate("RandomTemp");
docGen.DocumentElement(elementID, 2, "RandomTemp"); // gets the element by ID
docGen.SaveDocument("DOCUMENT.pdf", EA.DocumentType.dtPDF);

+: that would work for me either if i can reach somehow the package properties of the element too.

Thanks in advance.

Tamas

docGen.insertTemplate prints out your template as is, without filling in the fields. Remove that line of code and it should be fine

The document will generate the report following your template just fine with the following line of code you put: docGen.DocumentElement(elementID, 2, "RandomTemp");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM