I am using Embarcadero Delphi XE2
I’m creating a fastreport (its not that important) and saving it to TStringStream
Next just for tests I output that TStringStream to file, and the PDF saves fine and opens fine. It weights about 40KB (less)
What I need to do next, is write this PDF (TStringStream) to SQL database through INSERT, the only thing I do to modify it is I replace all ” with “” because its within ” quotes, otherwise the SQL doesn’t work.
The strange thing is, when I load the file from database, or even to SELECT length(attachment) where the attachment is PDF data saved earlier. When I do that, the size is more than 50KB (for some PDF’s even about 70KB), and the PDF is whole blank.
I am forced to use a simple mysql unit for this project which doesn’t allow some setParams or saving it through Blob object which I googled. So I need an answer concerning this simple method. Insert TStringStream to SQL database.
The database field is type MEDIUMBLOB
Thanks in advance!
Jack
The problem was solved by:
Export through frxPDFExport,
override its stream to TMemoryStream,
Converting the TMemoryStream to Hex String
and INSERTING it to sql as ‘0x’+converted_hex_string
Thanks for help anyway,
hope this answer helps with similar problem
Important:
it had to be TMemoryStream because of some strange ASCII chars in PDF, so when I exported it to TStringStream and then converted to hex, it came out corrupted.
You can look up on the net there’s the function to convert byte array (TMemoryStream) to hexed string.
Jack.