I was trying to create a kind of ‘print preview’ window for my reports. I was doing this using the below script (or similar, varying depending on the report).
# Executes the report, overriding two parameters
overrides = {"StartSegment":event.source.parent.getComponent('Recipe List').StartSegmentSelected, "EndSegment":event.source.parent.getComponent('Recipe List').EndSegmentSelected}
bytesArray = system.report.executeReport(path="Furnace Recipe Sheet", project="Shop_Floor", parameters=overrides, fileType="pdf")
#opens the PDFPrintPreview popup and pushes the report to the viewer
popupWindow = system.nav.openWindow("Popups\PDFPrintPreview")
pdfViewer = popupWindow.getRootContainer().getComponent("PDF Viewer")
pdfViewer.loadPDFBytes(bytesArray,"Furnace Recipe Sheet")
The popup opens and the PDF gets displayed in the viewer, but the text is funky. There’s square boxes where the text should be. If I view the same report in a Report Viewer component, it displays properly, as does the PDF if I save a copy and open it in Adobe.
I was originally trying to create a dynamic Report Viewer popup, but setting a dynamic report path and linking the differing report parameters to popup window custom scripts was proving unreliable. The PDF seemed like a more generic approach (execute the report with whatever parameters that report needs and throw whatever comes out at the PDF viewer), but I’m running into this issue.
The only other clue I’m seeing is some text in the client console.
Feb 27, 2018 4:32:40 PM org.icepdf.core.pobjects.Document <clinit>
WARNING: PDF write support was not found on the class path
Feb 27, 2018 4:32:40 PM org.icepdf.core.pobjects.Catalog <clinit>
INFO: ICEsoft ICEpdf Core x.x.x x
Feb 27, 2018 4:32:40 PM org.icepdf.core.pobjects.ImageStream <clinit>
INFO: Levigo JBIG2 image library was not found on classpath
I had a similar issue with a table on a report, one of the column headers was displaying the boxes instead of text. It ended up being something to do with the text formatting. It was bold and white on a dark background. I retyped the text and readjusted the formatting entering the same settings. This seemed to reset things and the report started displaying correctly after that.
Thanks for the suggestion! I didn’t have time to try it yesterday, but I did today. Unfortunately, it doesn’t look like it made a difference.
I’m wondering if this type of operation is even supported by the components. It does seem odd though that the reporting system would generate a pdf that the pdf viewer has trouble viewing. Maybe a font issue? My gateway is running on Linux, but my client is a Windows 7 machine.
Actually I think it’s that exact problem as the squares seems to indicate a font is missing on the client viewing the report or something? A lot of fun (or wierdnes) can happen when fonts is included.
Ok, I haven’t had a chance to spin up a Linux client OS to try that, but I did try something else. I modified my script to save the report to disk instead of passing it to the PDF viewer component.
# Executes the report, overriding two parameters
overrides = {"StartSegment":event.source.parent.getComponent('Recipe List').StartSegmentSelected, "EndSegment":event.source.parent.getComponent('Recipe List').EndSegmentSelected}
bytesArray = system.report.executeReport(path="Furnace Recipe Sheet", project="Shop_Floor", parameters=overrides, fileType="pdf")
#opens the PDFPrintPreview popup and pushes the report to the viewer
#popupWindow = system.nav.openWindow("Popups\PDFPrintPreview")
#pdfViewer = popupWindow.getRootContainer().getComponent("PDF Viewer")
#pdfViewer.loadPDFBytes(bytesArray,"Furnace Recipe Sheet")
#lets try saving the byte array
path = system.file.saveFile("report.pdf")
if path != None:
system.file.writeFile(path, bytesArray)
Then, I added a button on the PDF Viewer popup that lets me change the file path to point to the report I saved on the local client drive.
At this point, it’s looking like it’s a problem with the PDF Viewer being unable to read pdf files written by the Reporting Module. This seems really strange, as one would think that they would be compatible. I was able to confirm this behavior on another (windows 7) client as well.
I never use the PDF viewer but we do generate PDF with the reporting and then email them out.
On a whim I just went and tested one in the PDF viewer and I am seeing some anomalies as well.
So then I opened the PDF inside of Acrobat Pro with editing and the text in the PDF is jumbled together in text fields that don’t belong together.
It seems the reporting module doesn’t do a very good job of keeping text together where it belongs?
I can’t post a screenshot here as it contains data.
One suggestion is, to use the Report Viewer to view the report inside of Ignition and not the PDF viewer.
I was actually originally going to use the Report Viewer, not the PDF viewer. However, I was wanting to have a single ‘Print Preview’ popup windows for all my reports. The problem lies in being able to dynamically link the report parameters. The different reports have different parameters, so, I can’t just bind them to a window custom property. As far as I can tell, I can’t pass a string of overrides to the report on window load either.
Open one in Acrobat Pro(or any PDF editing software) and you will see the mess of text boxes that have no rhyme or reason to the way they are grouped and drawn.
I’d also suggest looking at fonts, first, because the symptoms here are very typical of that.
I did want to jump in with a couple of things. Although the PDF Viewer is in the reporting module, those two things share almost no code in common and don’t use the same engines. So it’s very possible that one could make things not compatible with the other.
The engine on the PDF Viewer has needed an update for a while, and we’ve done that for 7.9.9. This has solved several font-related issues that have been reported with the PDF Viewer, so if all else fails try that when 7.9.9 beta comes out. (No idea when, sorry, but it’s going to QA very soon.)
I’ll look for that new PDF viewer component when it comes out!
In the mean time, any advice about approaching this from the Report Viewer angle? Is there any way to supply a list of parameters to a report viewer window that has a dynamic report path?
Consider JSON-encoding the parameters as another string on the root container so you can pass them in openWindow() (along with the report name) and script the decode after a delay to load the report instance.
I set a couple of items in the report to Courier New and Times New Roman. They show up properly in the Designer Preview screen. (The items under the table)
However, if I get the report to load in a report viewer in a client, the fonts are displayed properly. AND, if I right click and save to pdf on that report viewer, the fonts are now correct in Adobe Reader. I was not expecting that!
Are the parameters addressable just using the component.InsertReportParameterNameHere? I was looking in the documentation for a overrides or parameter dataset property, but I didn’t see one.
Also, just so I have it straight in my head, you are suggesting to open a popup window that has two custom parameters. One for the report name (which the report viewer is directly linked to) and another for the JSON string or dataset. After the report initializes, loop through the second property and set the report parameters to what was passed in? I’m a little fuzzy on the set report parameters part…