# PDF Viewer Blurry images

**URL:** <https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 15, 2020, 7:42pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311 "2020-01-15T19:42:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [January 15, 2020, 7:42pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/1 "2020-01-15T19:42:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 15, 2020, 7:47pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/2 "2020-01-15T19:47:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [January 15, 2020, 8:18pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/3 "2020-01-15T20:18:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 15, 2020, 8:32pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/4 "2020-01-15T20:32:03Z")

</div>

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

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![cesrom](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@cesrom](https://forum.inductiveautomation.com/u/cesrom)\
**Post date:** [January 15, 2020, 9:01pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/5 "2020-01-15T21:01:36Z")

</div>

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:

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![brendan.curran](https://avatars.discourse-cdn.com/v4/letter/b/cdc98d/32.png) [@brendan.curran](https://forum.inductiveautomation.com/u/brendan.curran)\
**Post date:** [January 16, 2020, 8:41pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/6 "2020-01-16T20:41:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Usha\_Vilash](https://avatars.discourse-cdn.com/v4/letter/u/b5a626/32.png) [@Usha\_Vilash](https://forum.inductiveautomation.com/u/Usha_Vilash)\
**Post date:** [March 9, 2024, 6:22am UTC](https://forum.inductiveautomation.com/t/pdf-viewer-blurry-images/31311/7 "2024-03-09T06:22:12Z")

</div>

You can check the resolution and quality of the images being displayed in the PDF viewer. Blurry images can result from low-resolution or poorly compressed images and for image compression you can try any online application such as [https://jpegcompressor.com/](https://jpegcompressor.com/) it compresses images without losing their quality.
