View Single Post
Old Feb 8th, 2008, 9:19 AM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Saving document into database

Quote:
Originally Posted by Robocop View Post
it can be done by converting the document into a binary data type
It does not have much to do with "converting" the file to a binary data type. The PDF document is already a binary file.

What you need to do is write a script to insert a text file into a column. However, there are two changes you need to make apart from that routine process.

1) Make that column type "BINARY".

BINARY(M) 
The BINARY type is similar to the CHAR type, but stores binary strings rather than non-binary strings. This type was added in MySQL 4.1.2.

2) When you are reading in the PDF document, make sure your read handle is opened with the "rb" (read binary) format, rather than the typical "r" or "rt" (read text) format.


Getting back on track, you said you want to retrieve the document from the database, and display it in a textbox. If you're using a textbox to display the output, then you don't want the binary. It seems you just want the text.

You might need to find some .doc and .pdf libraries that could do the processing and plaintext fetching for you. But converting a fully formatted document with pictures and a layout, into simple plaintext, is a very difficult task.
Sane is offline   Reply With Quote