read user input text from in pdf file
-
יום שלישי 06 מרץ 2012 15:05
Using the following code, I can read the text from a pdf file.
Question:
The code does not seem to read the text inside input form controls.
For example, if there is a textbox called txtName on the first page of the pdf file, the c# code does not pick it up whereas it only sees the actual text of the pdf.
Do you see why please?
Thanksstring strText = string.Empty;
string filename = @"D:\test.pdf";
PdfReader pdfReader = new PdfReader(filename");
for (int nPage = 1; nPage <= pdfReader.NumberOfPages; nPage++)
{
ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
PdfReader reader2 = new PdfReader(filename);
String s = PdfTextExtractor.GetTextFromPage(reader2, nPage, its);s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
strText = strText + s;
reader2.Close();
}string strInput = strText;
כל התגובות
-
יום שלישי 06 מרץ 2012 15:14
-
יום רביעי 07 מרץ 2012 08:13Thanks but it does not do what I have asked in my question.
-
יום רביעי 07 מרץ 2012 23:45
Hi mate,
You are PdfTextExtractor.GetTextFromPage(reader2, nPage, its); means read the text on file not field content. Check methods of component to read fields by name or identifier and get value of the fields against it.
There you go.
Thanks.
Mohammad Saidul Karim
- סומן כתשובה על-ידי Leo Liu - MSFTModerator יום שלישי 13 מרץ 2012 06:31
-
יום חמישי 08 מרץ 2012 07:18מנחה דיוןHi arkiboys,
How is it going now with Mohammad's suggestion?
If your problem still exist, you need to close this thread by marking some useful replies as answers and then post in the some dedicated forums as below to get better support:
http://old.nabble.com/iTextSharp-f4188.html.
http://support.itextpdf.com/forum.
Thanks for your understanding and have a nice day,Leo Liu [MSFT]
MSDN Community Support | Feedback to us
-
יום רביעי 14 מרץ 2012 15:22
"Hi mate,
You are PdfTextExtractor.GetTextFromPage(reader2, nPage, its); means read the text on file not field content. Check methods of component to read fields by name or identifier and get value of the fields against it.
There you go.
Thanks.
Mohammad Saidul Karim
Check methods of component to read fields by name or identifier and get value of the fields against it."
This is exactly what I am trying to do but do not know how?
Any thoughts please?
Thanks -
יום רביעי 21 מרץ 2012 16:04
private void button2_Click(object sender, EventArgs e) { string strText = string.Empty; string filename = @"C:\pdfTestFile.pdf"; PdfReader pdfReader = new PdfReader(filename); for (int nPage = 1; nPage <= pdfReader.NumberOfPages; nPage++) { ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy(); PdfReader reader2 = new PdfReader(filename); String s = PdfTextExtractor.GetTextFromPage(reader2, nPage, its); s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s))); strText = strText + s; reader2.Close();
Hi,
My goal is to read the texts inside the controls in the
.pdf file...
I am using the iTextSharp reference...
The C# code below only reads the texts (Initially typed in the
file) but NOT the texts typed in the controls.
Do you know how
to solve this please?
Thanks