Skip to main content
1-Visitor
July 1, 2019
Solved

Generate PDF file containing table from JSON response, dynamically

  • July 1, 2019
  • 4 replies
  • 1550 views

Hello everyone,

 

I am trying to create a custom extension in Thingworx which will generate a PDF file when a user clicks a button. The Thingworx mashup on which this button exists, will have a table full of data ( assume 100s of rows and 10 columns) which needs to be exported as a PDF report. In the mashup, the user has an option to select the duration for which the data in the table has to be displayed. The source for the data in the table is from a Json file from another system ( if it is relevant )

 

I have Created a PDF generation code in eclipse that creates a table with sample placeholder data. But I am unable to figure out how the table can be created dynamically based on the data in thingworx. For example, if the user selects report duration as two days, the PDF should contain rows for only two days of data. If the user selects 15days in mashup and click the button, then the report should have table amounting to data for 15days.

In short, the table structure should depend on the duration selected in Thingworx.

 

Apologies if this is a vague question, but any help/pointers will be greatly appreciated!

 

Thanks in advance 

Best answer by slangley

Hi @kkgooner.

 

There are some unknowns here but one way you could do this would be to store the data from the .json file in a stream which can be queried based on timestamps.  If you don't want to store the data in ThingWorx, is there some way you can request only the data needed from the external system?

 

Regards.

 

--Sharon

4 replies

slangleyCommunity ManagerAnswer
Support
July 2, 2019

Hi @kkgooner.

 

There are some unknowns here but one way you could do this would be to store the data from the .json file in a stream which can be queried based on timestamps.  If you don't want to store the data in ThingWorx, is there some way you can request only the data needed from the external system?

 

Regards.

 

--Sharon

kkgooner1-VisitorAuthor
1-Visitor
July 3, 2019

Hello Sharon,

 

Thanks for your response.

Regarding your possible solution where you have said that we can store the json data in a stream and then query  it based on timestamps, can you confirm if you mean Thingworx value stream? Just asking because I have seen that it can be used for Time-series data, but need to explore on using it for my case here.