using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.Text; namespace Sample_2012_Web_App { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnShowContent_Click(object sender, EventArgs e) { if (PDFFileUpload.HasFile) { string strPDFFile = PDFFileUpload.FileName; PDFFileUpload.SaveAs(Server.MapPath(strPDFFile)); StringBuilder strPdfContent = new StringBuilder(); PdfReader reader = new PdfReader(Server.MapPath(strPDFFile)); for (int i = 1; i <= reader.NumberOfPages; i++) { ITextExtractionStrategy objExtractStrategy = new SimpleTextExtractionStrategy(); string strLineText = PdfTextExtractor.GetTextFromPage(reader, i, objExtractStrategy); strLineText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(strLineText))); strPdfContent.Append(strLineText); reader.Close(); strPdfContent.Append("<br/>"); } lblPdfContent.Text = strPdfContent.ToString(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)