PDF viewer/report weirdness

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

Not quite sure what that means.

Any ideas?

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.

My gateway is running on Windows and my Client is on macOS. But that shouldn’t have much bearing as Java should be completely cross platform.

Might be worth a shot to try it on a client in the same favor of Linux as your gateway?

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.

1 Like

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.

path = system.file.openFile('pdf')
if path != None:
   event.source.parent.getComponent('PDF Viewer').filePath = path

When I open the file directly with Adobe Reader, I get the expected output.

However, when I point the PDF Viewer at the same file, I get the boxes again.

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.

Still think it’s a font issue, see link

https://en.wikipedia.org/wiki/Portable_Document_Format#Standard_Type_1_Fonts_.28Standard_14_Fonts.29

What font are you using where the ‘squares’ appear?

Arial, the default font for the report module. I'll try switching it to Courier or Helvetica and see what happens.

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.)

Thanks for chiming in, Kathy.

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.

What about just using a dataset?

Whole new level of weird happening…

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)

When I use the Save button I made to execute the report and save the byte array to disk, the fonts are all the same default font in Adobe Reader.

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!

Yeah, that's a better idea.

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...

Yes, when the report definition deserializes, the named parameters of the report become same-named custom properties of the report viewer.