Click here to Skip to main content
14,640,670 members
Rate this:
Please Sign up or sign in to vote.
I am Developing Online exam Project and need help in importing the data from the MS word Document / PDF Document to my SQL Server database. The document can have specific Format defined by Programmer but i am unable to read and import the details i want to provide simple upload link for the user and data should be imported to the database. i have done this for Excel it Works fine but I am unable to Import data from Word File and PDF File

FRONT END : ASP.NET C#
BACK END : SQL SERVER 2008
Posted
Updated 9-May-14 10:13am
v2
Comments
Vi(ky 9-May-14 16:15pm
   
use excel file instead of word and pdf
Codefroster 9-May-14 16:20pm
   
dear sir user needs facility of excel , word and pdf for importing questions
j snooze 9-May-14 16:52pm
   
Word you'll probably have to do similar to excel using the office interop to open and read.(Guessing) I've used itextsharp for opening and reading a pdf file. (link: http://sourceforge.net/projects/itextsharp/) Here's a sample method I used with the itextsharp dll to read through the file. Hope it helps.(**note _pdfFiles is just a string array of pdf file names from a file dialog box)<br>
 <br>
private void ReadPDF()<br>
{<br>
StringBuilder strText = new StringBuilder();<br>
string[] lines;<br>
 <br>
try<br>
{<br>
foreach (string pdfFile in _pdfFiles)<br>
{<br>
PdfReader reader = new PdfReader(pdfFile);<br>
 <br>
for (int page = 1; page <= reader.NumberOfPages; page++)<br>
{<br>
ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();<br>
String s = PdfTextExtractor.GetTextFromPage(reader, page, its);<br>
 <br>
s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));<br>
//split at carriage return line feed<br>
lines = s.Split('\n');<br>
foreach (string line in lines)<br>
{<br>
if (line.IndexOf(txtSearchText.Text) > -1)<br>
{<br>
AppendLine(line);<br>
}<br>
}<br>
}<br>
reader.Close();<br>
}<br>
}<br>
catch (Exception ex)<br>
{<br>
MessageBox.Show(ex.Message);<br>
}<br>
}
Codefroster 9-May-14 17:09pm
   
Thanx j snooze for help but can u help word documents

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100