cancel
Showing results for 
Search instead for 
Did you mean: 

retrieve a PDF of a blob field and create a PDF file in PB 10.5

Former Member
0 Kudos

Good excuse my English, I use the PowerBuilder 10.5 made a query to a database that contains PDF files with SelectBlob and want to transform it to a PDF file returns me corrupt file and double the size.

In PowerBuilder 9.0 if it works, please if you could help me and I'm 2 days with that problem.

The following is the function.

li_numarch = FileOpen (ls_pathname, streamMode !, write !, lockwrite !, Replace!)

li_numarch if <0 then return -1

ll_BlobLen = Len (a_blob)

If ll_BlobLen> 32765 Then

    If Mod (ll_BlobLen, 32765) = 0 Then

       li_Writes = ll_BlobLen / 32765

    else

       li_Writes = (ll_BlobLen / 32765) + 1

    End if

else

    li_Writes = 1

End if

ll_CurrentPos = 1

For li_Cnt = 1 To li_Writes

    ls_blob = BlobMid (a_blob, ll_CurrentPos, 32765)

    ll_CurrentPos + = 32765

    If FileWrite (li_numarch, ls_blob) = -1 Then

FileClose (li_numarch)

FileDelete (ls_pathname)

return -1

end if

Next

FileClose (li_numarch)

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Alexander;

   There are a few things to consider here in newer versions of PB that are Unicode now vs PB 9.x which was ANSI based. They are as follows:

1) Use the new Encoding parameter on the FileOpen ( ) method to read the PDF file in the correct ANSI for Unicode format.

2) The Blob ( ) methods all have a new Encoding option.

3) Replace the FileRead ( ) method with the FileReadEx() method.

HTH

Regards ... Chris