Click here to Skip to main content
15,115,261 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I save a report as jpg format in SQL server 2008. I want to show the report as pdf format when click a button. Please help me. I have given my code :
code for save
if (picUpload.FileName.ToString() != "")
    string StrImgName = picUpload.FileName.ToString();
    string ImgFileExtension = System.IO.Path.GetExtension(StrImgName);
    string picPath = "SCDoc/" + txtSCCode.Text.Trim() + "-P" + ImgFileExtension;
    DRLocal["ContImagePath"] = picPath;

Code for show report
string DocUrl;
getvalue = Request.QueryString["SCCode"].ToString();

DataTable DTLocal;

DTLocal = new DataTable();

string strSQL = "SELECT ContImagePath from tblSalesContract where SCCode='" + getvalue + "'";
ConManager.OpenDataTableThroughAdapter(strSQL, out DTLocal, true);
DTLocal.TableName = "Item";
DocUrl = DTLocal.Rows[0]["ContImagePath"].ToString();
Response.ContentType = "Application/pdf";

1 solution

I think you will have to convert the image to a PDF before showing it. Google iTextSharp which is a library which will allow you to create PDF. In your case, you will have to temporarily create pdf and show it. OR, for all the images saved, create a pdf and store it on file system and store the path in the database. On button click, show the pdf instead of getting the image path. Hope this helps.

Happy coding..!!
Sumon562 20-May-14 3:16am
Thanks for your suggestion. Please can you help me how can I use iTextSharp
Nayan Ambaliya 20-May-14 20:02pm
Refer to the below on code project:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900