0

I want to write PDF file in aspx page of ASP.NET

I have feild in my database(sql) table with datatype image.

I need to read bytes from db and write it in pdf format in aspx web page.

I dont want to export pdf file.

Lajja Thaker
  • 2,031
  • 8
  • 33
  • 53
  • Actualy I have scenario like I am uploading a PDF file and it saves in database as datatype Image. And the other side I want to retrive its content in PDF format which I want to write in aspx web page , dont want to export that file. – Lajja Thaker Jul 26 '12 at 06:39
  • 1
    Why would you upload a PDF file and save it as an image? You have the option of saving it into a VARBINARY field and then you'll only need to read the field contents into a byte and render on the web page with ContentType="application/pdf" – John Gathogo Jul 26 '12 at 06:42
  • do as @JohnGathogo suggested, why u are over complicating the problem by converting into image and then saving that image in db as binary, insted save pdf as binary in db. – Zia Jul 26 '12 at 06:51
  • http://mattgemmell.com/2008/12/08/what-have-you-tried/ – tom redfern Jul 26 '12 at 08:49

2 Answers2

2

@Zia @John Gathogo Image and varbinary(max) both can be used to store binary data (files) its better to use varbinary(max) as Image is deprecated.

Refer to this for reading pdf file saved in database http://chiragrdarji.wordpress.com/2007/08/31/storing-and-retrieving-docpdfxls-files-in-sql-server/

Rahul
  • 31
  • 2
0

I recommend to use iTextSharp. Try this link, which contains an example to convert a list of byte[] to pdf files.

Community
  • 1
  • 1
mrd
  • 2,095
  • 6
  • 23
  • 48