1. Shenn Sellers
  2. PowerBuilder
  3. Wednesday, 7 March 2018 19:39 PM UTC

I have a bunch of PDFs that are saved in our database using the OLE Database Blob control in a DataWindow.  Is there a way to save these PDFs as a standalone PDF file using code?  Right now, if I use the code below, I am unable to open the "Test.pdf".  Thanks.

integer li_FileNum
blob lb_blob
 
SELECTBLOB pdf_file INTO  :lb_blob
   FROM tadtp_class_attendance
WHERE emp_id = 193891
and class_id = 44
and seq_num = 1;
 
li_FileNum = FileOpen("D:\Users\ssellers\Downloads\Test.pdf", &
   StreamMode!, Write!, Shared!, Replace!)
FileWriteEx(li_FileNum, lb_blob)
FileClose(li_filenum)
Marco Meoni Accepted Answer Pending Moderation
  1. Wednesday, 7 March 2018 21:20 PM UTC
  2. PowerBuilder
  3. # 1

Hi Shenn,

please provide more info:

  1. is li_filenum <> -1?
  2. is filewriteex returncode <> -1?

If one of the two lines above fails, do you have write permission in the destination folder?

Instead, if the file is created and its size is > 0, what do you mean by "unable to open test.pdf"? Your PDF reader does not display it?

Best,

Marco

Comment
  1. Shenn Sellers
  2. Thursday, 8 March 2018 18:10 PM UTC
The blob saves fine to disk without any errors.  However, it was saved to the database using an OLE Database Blob column.  So the only way I know of to access this file is to Activate the OLE Database Blob column.  This automatically opens the PDF and saves it without using "Selectblob" or Updateblob".  I remember reading somewhere that using this approach adds some additional information to the file in order to work with the OLE Database Blob column.  So that is why using the "Selectblob" and saving it to disk doesn't allow it to be opened in a PDF Viewer.  So I'm trying to figure out how to extract the PDF using code so I don't have to do it manually.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.