I’m working with a user manual PDF from a contractor, and the client would like it available in a PDF reader in the client. I’ve tried pointing the PDF reader directly at the PDF, as well as uploading to the database as a blob.In both instances, none of the images within the PDF load, while text and table load just fine. If I export the pages to image files and create a new PDF from them, none of the information on the pages loads, and it just displays 18 blank pages.
I have not been able to find anything specifically regarding images in PDFs not loading, though I see that the PDF reader has limited support and known shortcomings in 7.9. I understand if its not possible, just looking for some guidance and to help save some time if this cannot be accomplished.
Happy to share what I can. I cannot share the specific user manual, but I have a couple other documents that mimic the behavior I am seeing. I’ve attached 2 files that do not render images or whole pages when displayed, either using a blob or directly specifying the file path from the PDF viewer.
# Find the path to the PDF file.
path = system.file.openFile("pdf")
# Check to ensure that the user actually selected a filepath.
if path != None:
# Read the file as bytes.
data = system.file.readFileAsBytes(path)
# Ask the user to enter in a filename.
# Will grab just the filename and extension from the path as a suggestion.
name = system.gui.inputBox("Enter a name for the file", path.split('\\')[-1])
# Check to ensure that the user entered a name for the file.
if name != None:
# Insert the data and name into the database.
system.db.runPrepUpdate("INSERT INTO File_Storage (FileName, Data) VALUES (?,?)", [name,data])
And displaying that document. For now I am manually setting the ID, until I am confident we can get this working.
#ID of user manual in File_Storage Folder
id = 7
#Query for the raw pdf data by using the id.
bytes = system.db.runScalarQuery("SELECT Data FROM File_Storage WHERE FileID_ndx = %d" % id)
name = system.db.runScalarQuery("SELECT FileName FROM File_Storage WHERE FileID_ndx = %d" % id)
#Load the bytes and the name into the PDF viewer component.
event.source.parent.getComponent('PDF Viewer').loadPDFBytes(bytes, name)
The only thing I had to change was a LONGBLOB not BLOB for the column type for PDF bytes.
I tweaked a few names just for testing, results look ok to me
def insert():
# Find the path to the PDF file.
path = system.file.openFile("pdf")
# Check to ensure that the user actually selected a filepath.
if path != None:
# Read the file as bytes.
data = system.file.readFileAsBytes(path)
# Ask the user to enter in a filename.
# Will grab just the filename and extension from the path as a suggestion.
name = system.gui.inputBox("Enter a name for the file", path.split('\\')[-1])
# Check to ensure that the user entered a name for the file.
if name != None:
# Insert the data and name into the database.
system.db.runPrepUpdate("INSERT INTO testing (name, data_blob) VALUES (?,?)", [name,data])
def retrieve():
#ID of user manual in File_Storage Folder
id = 1
#Query for the raw pdf data by using the id.
bytes = system.db.runScalarQuery("SELECT data_blob FROM testing WHERE idtesting = %d" % id)
name = system.db.runScalarQuery("SELECT name FROM testing WHERE idtesting = %d" % id)
#Load the bytes and the name into the PDF viewer component.
event.source.parent.getComponent('PDF Viewer').loadPDFBytes(bytes, name)
insert()
#retrieve()
Thanks for checking.
This client is running on 7.9.6 - I’ll spin up a 7.9.7/8/9/10 and see if / where this functionality shows up. I suspect it’s just an ignition version issue.
Confirmed on 7.9.12 with MSSQL that the PDF viewer has no problem displaying the PDFs in question.
I assume its an Ignition version issue, but I can’t find any more information. Maybe someone at IA will have more insight.