1. Faisal Hayat
  2. PowerBuilder
  3. Friday, 17 May 2019

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*/
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 */


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

Accepted Answer
Faisal Hayat Accepted Answer Pending Moderation

I was able to sort out the issue after changing datatype from TEXT to Binary in database.

Thanks for posting the solution!
  1. Armeen Mazda @Appeon
  2. Friday, 17 May 2019
There are no comments made yet.
  1. Friday, 17 May 2019
  2. PowerBuilder
  3. # Permalink

There are replies in this question but you are not allowed to view the replies from this question.