wish to read a table in a PDF file using C#.net.
I wish to read a table in a PDF file using C#.net.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Mar 23, 2009, 1:03 PM
//See http://itextsharp.sourceforge.net/tutorial/ch05.html
public bool Chap0501(string sFilePDF)
{
bool bRet = false;
Debug.WriteLine("Chapter 5 example 1: My First Table");
// step 1: creation of a document-object
Document document = new Document();
try
{
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.GetInstance(document,
new FileStream(sFilePDF, FileMode.Create));
// step 3: we open the document
document.Open();
// step 4: we create a table and add it to the document
Table aTable = new Table(2, 2); // 2 rows, 2 columns
aTable.AddCell("0.0");
aTable.AddCell("0.1");
aTable.AddCell("1.0");
aTable.AddCell("1.1");
document.Add(aTable);
bRet = true;
}
catch (DocumentException de)
{
this.Message = de.Message;
}
catch (IOException ioe)
{
this.Message = ioe.Message;
}
// step 5: we close the document
document.Close();
if (bRet)
this.Message = sFilePDF + " has been created";
return bRet;
}
bretPosted Mar 23, 2009, 11:08 AM