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
sathish kumar
NA
117
165.2k
how to read pdf file in asp.net using c#.net
Jun 11 2012 6:49 AM
hi friends....
i want to read .pdf file using c#.net code and have to save that file ... Below is my code ... But it reads only one page of a file. I want to read all the
pages of a file.
Anyone help me...
else if (extn.Equals(".pdf"))
{
string filePath = Server.MapPath("uploads/" + filename);
string pdfText = string.Empty;
PdfReader pdfreader = new PdfReader(filePath);
//for (int page = 1; page <= pdfreader.NumberOfPages; page++)
//{
ITextExtractionStrategy itextextStrat = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
// ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
String extractText = PdfTextExtractor.GetTextFromPage(pdfreader,i, itextextStrat);
extractText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText)));
pdfText = pdfText + extractText;
// byte[] bytes = Encoding.UTF8.GetBytes("?"); //bytes now holds 0xDB8C
// byte[] converted = Encoding.Convert(Encoding.Default, Encoding.UTF8, bytes);//converted now holds 0xC39BC592
//// string final = Encoding.UTF8.GetString(converted);
// string pdftext = Encoding.UTF8.GetString(converted);
pdfreader.Close();
query = "INSERT INTO Fileupload([category],[subcategory],[uid],[oid],[up_name],[demo1],[keyword],[fdata],[aflag],sizebyte) VALUES('" + dropcategory.SelectedValue + "','" + DropDownList1.SelectedValue + "','" + Session["user_id"].ToString() + "','" + txtOwnerId.SelectedItem + "','" + fname + "','" + demo1.Text + "','" + key + "','" +pdfText+ "',1,'" + size + "') ";
//}
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();// ExecuteScalar().ToString();
}
Thanks in Advance....
Reply
Answers (
6
)
How to maintain sesstion in paypal getway..
microsoft chart control