Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store pdf in memo field with filetostr. Is that save?? 4

Status
Not open for further replies.

rombout

Programmer
Jan 24, 2000
24
NL
Is it save to store pdf files in a memo field with filetostr and retrieve them with strtofile. Can the output become corrupted??
 
Hi Rombout and Mike

I differ with Mikes reply.

FILETOSTR() AND STRTOFILE() assume that the string processed is of character type. SO they will give the same results provided the type of file processed is TEXT type.

PDF files are not text files.. SO when the FILETOSTR is done on a PDF file, the string taken becomes a character string and the STRTOFILE will save it with a PDF extension but as a text file. SO PDF READER could fail the subsequent read.

Quick example..

cString = FILETOSTR(GETFILE("pdf"))
=STRTOFILE(cString,"Test.PDF")

Now open the Test.pdf using a PDF reader.

:)





ramani :)
(Subramanian.G)
 
Hi Ramani I tested your example and encountered no problems. But maybe with a different version(5.1) of the Reader it could fail.
Do you know a way to make it saver.

Because from an application I wrote we send pdf files by mail to our clients and when the mail is send I want to be able to send it again. So I had the plan to store the files, with filetostr(), in a table memo field.


Rombout
 
Hi Rombout

If it worked, that is nice. I need to stand corrected. But let me try in reality.

Another important thing is that, fileToStr and StrToFile failed in few cases WHEN the fileSize was large. You have to take care in that area also.

Just to send PDF file by email, you dont have to do the code as explained. You can make an attachment of the PDF file directly.. or by simply renaming it to a new name with .pdf and then attach that. It will be lot more safer and simpler that way.

:)

ramani :)
(Subramanian.G)
 
Ramani,

FILETOSTR() AND STRTOFILE() assume that the string processed is of character type. SO they will give the same results provided the type of file processed is TEXT type.

PDF files are not text files.. SO when the FILETOSTR is done on a PDF file, the string taken becomes a character string and the STRTOFILE will save it with a PDF extension but as a text file. SO PDF READER could fail the subsequent read.


I'm not sure I follow that. What do you mean by a text file in this context? Surely, a PDF is just a series of bytes, as is any other file. I might be wrong, but I can't see any reason why FILETOSTR() and STRTOFILE() shouldn't be reversible, regardless of what the file actually contains.

The only possible problem would be if STRTOFILE() appends an eof character (ASCII 26) to the file, but as far as I can see in my tests, that is not the case.

Mike


Mike Lewis
Edinburgh, Scotland
 
rombout,

Rather than take a chance on corruption, why not just store the PDF file in a separate directory and put the filename (including full path) into a character field in the database? That would probably also avoid future issues with the memo file (.FPT) becoming unmanageably large.

Mike Krausnick
Dublin, California
 
rombout

If you really need to store the .pdf in a memo field, why not simply put the .pdf into the memo field as is, and ignore the use of FILETOSTR() and STRTOFILE()?

I don't understand the purpose of the conversion?

A .pdf file is already compressed - place one in a .zip file and you will see what little difference it makes, so including them in their natural state in a memo field will not cause any significant 'bloat'.

FILETOSTR() is extremely demanding on RAM as it reads the entire file into memory.

If you use the function on a large file on a low specification user machine, you may well run into problems.

FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
Hello everybody thanx for all the replies.

I wil put the pdf files in a seperate directory. I understand that is most save way to do it.


Rombout
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top