Dynamic Text in Reports ArgGIS Pro SDK

785
7
05-14-2024 06:33 AM
RITASHKOUL
Regular Contributor

 

Hi,

I am trying to create a report using ArcGIS Pro SDK APIs. I am able to create a basic structure that will contain fields and their values in the details section. I am also able to add some statistics for the report.

We have a use case to have some fields with dynamic data that should be loaded/filled during the report creation. I tried using a way of dynamic text, under which I created a rectangle text and used this tag: "ObjectId: <dyn type="report" property="field-value" field="OBJECTID"/>". But this is not working when I am exporting the report to PDF.

Can we have dynamic field data in the header section of the report? These fields or data will not be shown as part of tabular data which we generally have in the details section. This we are trying to show some extra data in the header besides the regular fields data and not in the tabular form but simply a list form.

@UmaHarano @GKmieliauskas @Wolf @CharlesMacleod @NarelleChedzey 

Tags (1)
0 Kudos
7 Replies
UmaHarano
Esri Regular Contributor

Hi

Dynamic text with "field value" can be added to a Field element in a report. This allows you to modify the field values in your report for that particular field. You will see this behavior with the Report UI. This same behavior should be supported via Report creation with the API.

UmaHarano_0-1715707365781.png

 

0 Kudos
RITASHKOUL
Regular Contributor

@UmaHarano Can u point me to the documentation or the code snippet? Because when I am trying to insert field value in the report header, Field Value is disabled in Insert tab. In the documentation  as well as the code snippet, it is mentioned that field value can inserted only in

RITASHKOUL_0-1715748411215.png

GraphicElement fieldHeaderGraphic = ReportElementFactory.Instance.CreateRectangleParagraphGraphicElement(reportsSection, newHeaderFieldEnvelope, field.Name);

But using the above it is creating the field but not adding its dynamic value but exporting it as it is in the pdf file

RITASHKOUL_0-1715784637751.png

For my use case besides fields section I need data like Label : {value} somewhere in the header(above field section) and then in runtime I need to update the value of data Label. Or can we create this section completely runtime without the placeholder. So from scratch can I create this Label:value?

I need data/structure like this in the pdf file

------------------------------------------------------------------------------------------------------------------------------------------------------

Label1: value             Label2: value

Label3:value              Label4:value

Page Header Section:

Details Section:

Page footer Section:

Report footer Section:

-------------------------------------------------------------------------------------------------------------------------------------------------------

@GKmieliauskas @Wolf @CharlesMacleod @NarelleChedzey 

0 Kudos
UmaHarano
Esri Regular Contributor

Hi

Field values for a attributes are only displayed in the "ReportDetails" section of a Report. In the Report UI, you will notice that the "Insert Tab> Field button (Data group) is only enabled when you select the "Details" section in the Report TOC. In the screenshot below, notice how I have selected the Details section in the TOC and hence the Field button in the ribbon is enabled.

UmaHarano_0-1715807441686.png

 

 

0 Kudos
RITASHKOUL
Regular Contributor

@UmaHarano  But now my question is, besides the attribute or field data in tabular form, is there any other place I can have some dynamic data in the below format:

Label1: value1          Label2: value2

Label3: value3          Label4: value4

I can see a method:

ReportElementFactory.Instance.CreateRectangleParagraphGraphicElement(reportHeader, newFieldEnvelope, item)

Here I can set the value of item as Label1:value1 but then challenge will be from where to start and end and also how to decide to set the width of that element(because small width can truncate the element value). In the code snippets, reference is taken from the last element added but if there is no last element and we are adding the elements from the scratch then it will be challenge to create the above structure having labels and their values.

Also there is a problem if the value is too large for the element its not wrapping the value but truncating it?

0 Kudos
UmaHarano
Esri Regular Contributor

Hi!

You should be able add dynamic texts to the Report Header section.  The method you listed is correct. 

  • It will definitely be a design challenge to site an array of text elements in the Header section. 
  • Are you seeing any word wrapping problems for texts with many characters? CreateRectangleParagraphGraphicElement should automatically wrap, so please let us know if you are running into issues there.
0 Kudos
RITASHKOUL
Regular Contributor

Dynamic texts when added to report header are not exported correctly to pdf. The value is exported as it is. So if dynamic text is {OBJECTID} it is not exporting object id’s value but exporting as it is which is {OBJECTID}

I am seeing wrapping issues as well for both scenarios: Details(fields) section as well element created using CreateRectangleParagraphGraphicElement

RITASHKOUL_0-1715928783125.png

As you can see at the top there are 2 paragraphic elements but they are also truncated. As well as field values are also getting truncated (GUID and string values in 2nd and 3rd columns)

@UmaHarano 

0 Kudos
UmaHarano
Esri Regular Contributor

Hi!

Regarding dynamic texts in the report header, the only dynamic tags supported are in listed in this help page: https://pro.arcgis.com/en/pro-app/latest/help/reports/dynamic-report-elements.htm

Anything related to features in the report data source are only relevant in the Fields section (ReportDetails). They cannot be used in the Header.

Thanks for letting me know about the wrapping issues. I will share this info with the Reports Dev team.

Uma

 

 

0 Kudos