Use PDF from DB to view in PDF viewer in perspective using WebDev

Hi,
I want to display a PDF in PDF viewer in perspective that is saved in DB in blob format using WebDev.

this is the code I wrote in WebDev doget()

my_pdf=system.db.runNamedQuery( "folderName/myNamedQuery" , {})
return {'contentType':'application/pdf','bytes':my_pdf}

The above code doesn’t seem to work
how can this be done?

Named queries return a dataset. You need to pull the blob content out of the dataset. Something like this:

myds=system.db.runNamedQuery( "folderName/myNamedQuery" , {})
my_pdf = myds.getValueAt(0, 'myBlobColumnName')
return {'contentType':'application/pdf','bytes':my_pdf}
1 Like

You might also find this helpful:

1 Like