Is it possible to save a pdf file into a memo field?

Is it possible to save a pdf file into a memo field?

Postby hua » Tue Nov 06, 2012 8:09 am

Hi,
Is it possible to save/retrieve a pdf file to a memo field (without having to resort to ADS)?

If it is could anyone share some code snippets?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1040
Joined: Fri Oct 28, 2005 2:27 am

Re: Is it possible to save a pdf file into a memo field?

Postby StefanHaupt » Tue Nov 06, 2012 9:13 am

maybe you can do it with blob, but I have noe xperience with it.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Is it possible to save a pdf file into a memo field?

Postby Gale FORd » Tue Nov 06, 2012 2:42 pm

Code: Select all  Expand view

#INCLUDE "DBINFO.CH"
#INCLUDE "FILEIO.CH"

function my_file2blob( cFileName, cFieldName )
   local nHandle, lReturn := .f., bFieldBlock, cFileBuf
   local nPos
   bFieldBlock := fieldblock( cFieldName )
   nHandle := fopen( cFileName )
   if nHandle = -1
      Alert("Cannot access file " + cFileName)
   else
      nPos := fseek( nHandle,0,FS_END)
      if nPos > 0
         fseek( nHandle,0,FS_SET)
         cFileBuf:=space(nPos)
         fread(nHandle,@cFileBuf,nPos)
      endif
      lReturn := fclose(nHandle)
      if lReturn
         eval( bFieldBlock, cFileBuf )
      endif
   endif
return( lReturn )

function my_blob2file( cFileName, cFieldName )
   local nHandle, lReturn := .f., bFieldBlock
   bFieldBlock := fieldblock( cFieldName )
   nHandle := fcreate( cFileName )
   if nHandle = -1
      Alert("Cannot create file " + cFileName + ", export failed!")
   else
      if fwrite( nHandle, eval( bFieldBlock ) ) > 0
         lReturn := fclose( nHandle )
      else
         fclose( nHandle )
      endif
   endif
return( lReturn )


 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Is it possible to save a pdf file into a memo field?

Postby hua » Wed Nov 07, 2012 1:14 am

Thanks Stefan and Gale :)
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1040
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 21 guests