TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Thulasiram pakala
907
872
115.3k
convertded pdf to image and store folder
Sep 22 2016 3:35 AM
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)
{
//first save pdf file in root folder
fn = FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath(
"pdf/"
) + fn);
}
//pdf file path return for convert
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);
// lblMessage.Text = "Directory created on server.";
}
else
{
lblMessage.Text =
"Directory already exists."
;
}
//path for save converted images
// string SaveImageToFolder = Server.MapPath("ConvertedImage");
PDFConvert Pconverter =
new
PDFConvert();
bool
Converted =
false
;
Pconverter.JPEGQuality = 2000;
Pconverter.OutputFormat =
"jpeg"
;
Pconverter.OutputToMultipleFile =
true
;
// Pconverter.Height = 2000;
// Pconverter.Width = 1526;
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);
//Passing parameters to query
//int i = 1;
// i++;
cmd.Parameters.AddWithValue(
"@Journal_ID"
, folderName);
cmd.Parameters.AddWithValue(
"@ImagePath"
, directoryPath);
// cmd.Parameters.AddWithValue("@ImagePath", "E_journal_uploads/" + folderName +input.Name+i+".Jpeg");
cmd.ExecuteNonQuery();
con.Close();
input.Delete();
//delete pdf file after converted!!!
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;
}
Attachment:
pdf.rar
Reply
Answers (
4
)
What is Jarray and Jobject in mvc
Validation failed for one or more entities. See 'EntityValid