Hi
What i am doing i convert pdf files in to jpeg format what happened its converted one pdf page to one image file and store on one folder what i need i need to store this all jpeg to database i am using this code and call pdf dll file anyone help
hear i am attaching coding what i need after storing jpeg files need to store in data base that all files in one id
- protected void btnPDFToImage_Click(object sender, EventArgs e)
- {
- string fn="";
- try
- {
- if (FileUpload1.HasFile)
- {
-
- fn = FileUpload1.FileName;
- FileUpload1.PostedFile.SaveAs(Server.MapPath("pdf/") + fn);
- }
-
- string Path = Server.MapPath("pdf/" + fn);
- string serverDirectory = Server.MapPath("E_journal_uploads");
- string folderName = TextBox1.Text;
- string directoryPath = serverDirectory + @"\" + folderName;
- if (!Directory.Exists(directoryPath))
- {
- Directory.CreateDirectory(directoryPath);
-
- }
- else
- {
- lblMessage.Text = "Directory already exists.";
- }
-
-
- PDFConvert Pconverter = new PDFConvert();
- bool Converted = false;
- Pconverter.JPEGQuality = 2000;
- Pconverter.OutputFormat = "jpeg";
- Pconverter.OutputToMultipleFile = true;
-
-
- Pconverter.Height = 950;
- Pconverter.Width = 750;
- Pconverter.FitPage = true;
- Pconverter.TextAlphaBit = 4;
- System.IO.FileInfo input = new FileInfo(Path);
- string output = string.Format("{0}\\{1}{2}", directoryPath, input.Name, ".jpeg");
- Converted = Pconverter.Convert(input.FullName, output);
- con.Open();
- SqlCommand cmd = new SqlCommand("Insert into Journals(Journal_ID,imagepath) values(@Journal_ID,@ImagePath)", con);
-
-
-
- cmd.Parameters.AddWithValue("@Journal_ID", folderName);
- cmd.Parameters.AddWithValue("@ImagePath", directoryPath);
-
- cmd.ExecuteNonQuery();
- con.Close();
- input.Delete();
- lblMsg.Text = "Pdf converted into images successfully!Check folder";
- }
- catch (Exception ex)
- {
- lblMsg.ForeColor = System.Drawing.Color.Red;
- lblMsg.Text = "an error occured.<br />";
- lblMsg.Text = ex.Message;
- }