none
How do I extract control attributes of specific text from pdf using c# RRS feed

  • Question

  • Hi,

    I have pdf files from which I need to extract specific text(ex: invoice no) control attributes like other RPA tools do 

    EX: <wnd app='acrord32.exe' cls='AcrobatSDIWindow' title='invoice3.pdf - Adobe Acrobat Reader DC' />
    <wnd cls='AVL_AVView' title='AVPageView' />
    <ctrl idx='1' role='row' />
    <ctrl name='Invoice Number: AT-30411567   ' role='text' />

    Is anyone knows please help me to solve this

    Wednesday, November 1, 2017 5:58 AM

All replies


  • Hi Sunitha_Bist,

    >>How do I extract control attributes of specific text from pdf using c#

    You can use ITextSharp to extract plain text from PDF documents.

    The following code for your reference.

                string TempsaveFilename = @"D:\hello2.pdf";
                PdfReader pdfReader = new PdfReader(@"D:\hello.pdf");
                PdfStamper stamper = new PdfStamper(pdfReader, new FileStream(TempsaveFilename, FileMode.Create), '\0', true);
                AcroFields fields = stamper.AcroFields;
                AcroFields pdfFormFields = pdfReader.AcroFields;
                foreach (KeyValuePair<string, AcroFields.Item> kvp in fields.Fields)
                {
                    string FieldValue = "a";
                    if (FieldValue != "")
                    {
                        //var oldvalue = pdfReader.AcroFields.GetField(kvp.Key);
                        fields.SetField(kvp.Key, FieldValue);
                    }
                }
    
                stamper.FormFlattening = false;
                stamper.Close();
                pdfReader.Close();


    The following articles for your reference.

    Reading PDF form fields using iTextSharp:
    https://community.dynamics.com/crm/b/crmmitchmilam/archive/2012/11/14/reading-pdf-form-fields-using-itextsharp

    Extract Text from PDF in C# (100% .NET):
    https://www.codeproject.com/Articles/14170/Extract-Text-from-PDF-in-C-NET


    Best Regards,

    Yohann Lu



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Fei HuModerator Thursday, November 16, 2017 2:00 AM
    Thursday, November 2, 2017 3:21 AM
    Moderator