Read contents of PDF file and display in a html format
I want to convert the PDF document to HTML format. I have no idea of from where to start.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Jan 22, 2014, 7:30 PM EST
Praveen N104 reputationPosted Feb 13, 2014, 6:54 PM EST
Best would be convert PDF to text file and later text to PDF.
.aspx Page
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> xmlns="http://www.w3.org/1999/xhtml"> id="Head1" runat="server"> Untitled Page id="form1" runat="server"> ID="FileUpload1" runat="server" /> /> ID="btnRead" Text="Convert" runat="Server" OnClick="btnRead_Click" /> /> ID="txtContent" runat="Server" TextMode="MultiLine" Height="376px" Width="411px">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnRead_Click(object sender, EventArgs e) { string appPath = Request.ApplicationPath; System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.Arguments = " -raw -htmlmeta" + " " + FileUpload1.PostedFile.FileName + " " + "D:\\output.htm"; ; p.StartInfo.FileName = Page.MapPath("pdftotext.exe"); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = false; p.StartInfo.RedirectStandardOutput = false; p.Start(); p.WaitForExit(); System.Threading.Thread.Sleep(3000); txtContent.Text = ReadFile("D:\\output.htm"); } public string ReadFile(string s) { StreamReader sr = new StreamReader(s); string strReturn = sr.ReadToEnd(); return strReturn; } }http://www.c-sharpcorner.com/UploadFile/saurabhnandu/TexttoHTMLParser12032005072354AM/TexttoHTMLParser.aspx
OR
the alternate way to do
Download the dll Aspose.Pdf.dll from http://www.aspose.com/docs/display/pdfnet/SaveFormat+Enumerationand rest assured only two lines of code in your code-behind file :)
Regards,
Praveen Nelge