Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using fileupload control to save a tiff and PDF files in SQL database. I am saving the file in byte format.

I am using the below code to display in PDF file where the byte array is a original PDF byte array stream.

 byte[] image;
            dr = cmd.ExecuteReader();
            dr.Read();
            image = ((byte[])dr["DocImage"]);
            Response.Clear();
            MemoryStream ms = new MemoryStream(image);
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + LNKBTN.Text);
            Response.AddHeader("Content-Length", image.Length.ToString());
            //Response.WriteFile(LNKBTN.FullName);
            Response.Buffer = true;
            ms.WriteTo(Response.OutputStream);
            Response.End();
            cn.Close();

But what is needed to be done is case of retreiving a TIFF byte array. After retreiving the byte array of the TIFF file from the database I need to convert the TIFF byte array to PDF bytes and I need to show the content in PDF file. How can i achieve the same using Itextsharp.

Please post some code snippet to achieve the same.

Thanks in advance...

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

This code should get you started hopefully. They load the TIFF from disk but you can very easily do that from a byte array. Basically it loops through each page of the TIFF (or the only page if you just have 1) and adds them to a blank PDF page.

http://www.atashbahar.com/post/Converting-Multipage-TIFF-image-to-PDF.aspx

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.