PDFViewer clear active PDF

I’m using the Vision -> Reporting -> PDF Viewer to display PDF’s loaded from a SQL Database as bytes.

I can load a PDF without issue, but I’m trying to figure out how to actually then clear out the loaded PDF at runtime.

I’ve tried this:

emptyPDF = system.file.getTempFile('pdf')
pdfByes = system.file.readFileAsBytes(emptyPDF)
try:
	event.source.parent.getComponent('pdfViewer').loadPDFBytes(pdfByes,'')
except:
	#This will create an error. That's ok.
	pass

However I get an ICEpdf error popup that I can’t seem to avoid. I’m fine with it throwing an error, I just don’t want to see it in this instance.

Is there any good way to do clear out the loaded PDF?

Have you tried using an empty list instead of an empty string?

Same error. This is what it displays

image

Which I get because it’s an empty file. I just don’t want to see the exception when I do this.

event.source.parent.controller.closeDocument(), maybe?

event.source.parent.getComponent(‘PDF Viewer’).getController().closeDocument()

@PGriffith was correct first.

His suggestion also works:
event.source.parent.getComponent(‘PDF Viewer’).controller.closeDocument()

1 Like

This worked like a charm.

Thanks!