Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi,
I need to create a custom PDF extension widget for Thingworx. This widget should be able to export the data ( infotable containing of many rows and columns) shown in thingworx as a PDF. For my testing purpose, I created a sample Json file in my local computer and used that as a source for the java code to get the PDF generated.
Now how I have to test using the data coming from Thingworx. Can you please suggest me how can I achieve this? The json data from thingworx should be passed as the input to my java code where pdf is generated.
Much thanks..
Solved! Go to Solution.
Hi, I have not tried what you suggested. Some one in the community might help you out with that. But what I am trying to suggest is create a Web Service or Rest API in your Java code. I believe you can invoke this API from ThingWorx service, through the code snippets which I have mentioned earlier, and pass the JSON values. Again, this might not be the best option and what you have suggested might work. But this is also a way you can achieve what you are looking for. Hope this helps!
ThingWorx provides ability to make calls to Web service. Refer to the code snippets section which is available to you while creating a service and find the ContentLoaderFunctions section. Here you can find different methods to export/import json through ThingWorx to an external program.
Hi,
Thank you for your response. I will have a look. Whatever you said is applicable for a custom extension that I will be importing into thingworx? Because I need to pass data from one thingworx service (json output) to this widget ( where that data will be the input)
Also, based on your reply, I have got the below idea. Please let me know if its feasible.
1.In my custom widget java code, I have defined @ThingworxServiceDefinition( name="pdfservice").
2. So once I import the extension to Thingworx, I create a Thing for this extension and map this pdfservice to this thing.
3. Then in the input section of this pdfservice, I can pass the service that provides the initial json data that will be used for the pdf reports.
Not sure about the logical flow of this, but just got a rough idea. Let me know if this is feasible in Thingworx. Thanks
Hi, I have not tried what you suggested. Some one in the community might help you out with that. But what I am trying to suggest is create a Web Service or Rest API in your Java code. I believe you can invoke this API from ThingWorx service, through the code snippets which I have mentioned earlier, and pass the JSON values. Again, this might not be the best option and what you have suggested might work. But this is also a way you can achieve what you are looking for. Hope this helps!