PDF Viewer Blurry images

So I’m trying to to display alerts in the PDF viewer by reading byte array data from a database. Everything seems to be functioning decently, but the images are incredibly blurry. The text is basically unreadable. Is this a limitation of data loss when converting back and forth from byte arrays, or is this a bug or something I can fix?

Sounds more like a problem with how the data’s getting into the database. By definition, a byte array should be an exact replication of the raw data in a PDF. How are you putting the data into the DB?

path = system.file.openFile("pdf")

if path != None:
    data = system.file.readFileAsBytes(path)

    system.db.runPrepUpdate("INSERT INTO quality_alert_pdf (pdf) VALUES (?)", [data])
	
data = system.db.runQuery("select pdf from quality_alert_pdf")
system.tag.write("[client]PDF Dataset", data)
size = data.getRowCount()
index = 1
system.tag.write("[client]manage index", index)
displayStr = str(index) + " / " + str(size)
if data.getRowCount() > 0:
	pdf = data.getValueAt(0,"pdf")
	system.gui.getParentWindow(event).getComponentForPath('Root Container.PDF Viewer').loadPDFBytes(pdf, "pdf") 

Just an excerpt with the upload and display.

I get no blur on 7.9.10 using similar code. Is the datatype of your SQL column BLOB?

I use a dropdown to change PDF’s

Do note I am using Scalar SQL return

if event.propertyName == "selectedValue":
	id = event.newValue   #First get the id from the dropdown.
	bytes = system.db.runScalarQuery("SELECT FileBytes FROM dummy_pdf WHERE id = %d" % id)  #Query for the raw pdf data by using the id.
	name = system.db.runScalarQuery("SELECT Filename FROM dummy_pdf WHERE id = %d" % id)   #Query for the file's name by using the id.
	event.source.parent.getComponent('PDF Viewer').loadPDFBytes(bytes, name)

I never reported this “issue” to IA Staff, but I was facing a problem with one of my reports where some lines were not displaying and the chart data was hard to read. Maybe it’s the same thing you’re facing.

I ended up writing a temp file, and passing the path to the PDF Viewer component like this:

# Set Report Path
report_path = "path/to/report"

# Create temp file
temp_file = system.file.getTempFile("pdf")

# Set report parameters and execute
params = {
    ...
}
bytes = system.report.executeReport(path=report_path,
                                    parameters=params,
                                    fileType="pdf")

# Write bytes into temp file
system.file.writeFile(temp_file, bytes)

# Finally bind the temp_file path to the File Path property of the
# PDF Viewer component.

After the client is closed, all temp files will/should be deleted.

Hopefully this helps.

Tried all of the above. No luck. Entire PDF image looks compressed and blurry when running the live client.

Edit: Even converting the file to bytes then immediately converting it back to be displayed as a PDF results in image compression. Even directly referencing the file location results in a blurry image.

This is a component issue with the PDF viewer. Guess I’ll have to find an alternative.