Hi All
I am trying to save a pdf file in database and then fetching pdf data from database to create pdf file from it. BUT the created pdf file is not being opened showing message that it damaged or corrupt. Here are the implementation details
PowerBuilder: 2017 R3
Database: Informix
PDF data holding column type: TEXT
Saving Data:
long ll_file, ll_bytes, ll_pdf_key = 1
blob lblob_file
ll_file = FileOpen("C:\test.pdf", StreamMode!)
ll_bytes = FileReadEx(ll_file, lblob_file) /* ll_bytes value is 7982565*/
FileClose(ll_file)
if ll_bytes > 0 then
Updateblob table_pdf
set pdf_data = :lblob_file
where pdf_key = :ll_pdf_key
using SQLCA;
end if
Fetching Data and write to PDF
blob lb
long ll_file, ll_count, ll_pdf_key = 1
selectblob pdf_data
into :lb
from table_pdf
where pdf_key = :ll_pdf_key;
ll_file = FileOpen("C:\generate.pdf", StreamMode!, Write!, LockReadWrite!, Replace!)
ll_count = FileWriteEx(ll_file, lb) /* ll_count value is 7982564 */
FileClose(ll_file)
As I have highlighted counts above I think I am missing or having extra BOM character or I am using wrong column data type. Your help will be highly appreciated. Thanks