Skip to main content
16-Pearl
July 23, 2024
Solved

Printing a Mashup on runtime

  • July 23, 2024
  • 1 reply
  • 933 views

Good day, everyone

 

I am trying to print my webpage/mashup, (an image just for now).

Following this article guide: https://www.ptc.com/en/support/article/CS319138

I wrote the below in a service and I invoke this service on a button click with the hopes of getting the print page to open up (Like how it would when you press Ctrl+P).

This isn't working. Is there something I am missing?

 

The code: 
let table = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "dataShape_DS"
});
let html = "window.open('http://xx.xx.co/:port/Thingworx/MediaEntities/Icon'); html.print()";table.AddRow({htmlColumn:html});
result = table.htmlColumn;

Best answer by Sathishkumar_C

I have tested in my local and it's working fine with value display. I tried as follow,

  1. Create a persistent  property (name: html_property) with HTML as a base type
  2. Set below string as a property value
    <button onclick="let WindowReferenceObj = window.open('http://localhost:8080/Thingworx/MediaEntities/AcknowledgeAlertIcon'); WindowReferenceObj.print();">Print</button>
  3. Write service which return the property value and output as HTML
    result = me.html_property
  4. Create a mashup with Value display and render as HTML

1 reply

17-Peridot
July 24, 2024

I have tested in my local and it's working fine with value display. I tried as follow,

  1. Create a persistent  property (name: html_property) with HTML as a base type
  2. Set below string as a property value
    <button onclick="let WindowReferenceObj = window.open('http://localhost:8080/Thingworx/MediaEntities/AcknowledgeAlertIcon'); WindowReferenceObj.print();">Print</button>
  3. Write service which return the property value and output as HTML
    result = me.html_property
  4. Create a mashup with Value display and render as HTML