Hi All,
I wanted to convert binary data from database to pdf. Following are the detailed steps
Fetch the data from database which is in binary format. Eg In table ABC i have coloumn name as XYZdata which is binary data.
Read each of the binary data and convert in to PDFfile.
It would be really great if any of you provide me a detailed solution as i am struggling to do from past two days.
Hi @aanandsanraj
Thank you for the response. I am actually looking for the 4th step “Get the binary data and convert to byte” . It would be great if you brief it more.
From database you will get the binary data as string in a column. We cannot directly use that as string, so we need to convert that string to byte. Then only we can save that byte as pdf file.
I understood the logic but I am not able to implement. Below is the sample table
ItemID ItemData
1 0100100 (Binary format)
2 0100100 (Binary format)
3 0100100 (Binary format)
Now i need to fetch the data under the column item data and need to convert in to bytes and then in to PDF not sure how to implement. WHen i tried to fetch the coloumn details its just printing me “system.data” in write line instead of content in each cell.
can you help me how to convert the binary data from string to bytes. so that from there i can try to convert it to PDF
Does binary code holds any pdf file? I thought entire pdf file stored as binary data in database. Please clarify the requirement I might understand it wrongly.
yes your understanding is correct. The entire PDFfile is stored as binary data in database.
You have mentioned as to convert from string in to bytes. I am not able to get that coloumn in to string. Could you provide me the steps for this part. so that i can take it from there.
Thankyou very much . I incorporated your code and I am sucessfuly able to download the PDF. BUt i am unable to open the file "Its thorwing me a error message as " could not open xyz.pdf becuase it either supported file type or because the file has been damaged(For example it was sent as an email attchment or wasnt correctly decoded). This is the mesage I am getting .