1

I have been trying to parse pan card details to appropriate fields. But I could not parse correctly. Here I have used regex to find pan card number and date of birth and results perfect. But I could not able find the first name and last name correctly because position are changing.

There are two type of Pan card:

1.) Pan card one contains first name, last name, pan card number, dob. 2.) Pan card second contains Name: user name, father's Name: user father name, pan card number and dob

Here is the block three different text:

Pan card Type: 2

  **Block detected text 1:**

  sira
  feminT
  INCOME TAX DEPARTMENT
  Hd FOR
  GOVT. OF INDIA
  earril then tea ard
  Permanent Account Number Card
  argi Name
  EJWPM0714E
  FARHAZ MALIK
  frat ast aral Father's Name
  SHAKEEL MALIK
  a aale/ Dete of Bi-th
  08/08/1996
  ner Signature
  19012018

  **Block detected Text 2:**

  BITeTE fATHTST
  HRA TROR
  Scale document up. DEPARTMENT
  INVUND
  GOVT. OF INDIA
  Arne ste
  RITA cRaT Fran Tis
  Permanent Account Number Card
  ILDCK6689J
  T / Name
  SANJANA
  furat nT FITH / Father's Name
  CHALAMESH
  : sanjans
  10042019
  Tre aft arita
  Date of Birth
  06/06/1996
  & FaT&R / Signature

Pan card Type 1:

 **Block detected Text 1:** 

  vSTreTa T feTHIST
  INCOME TAX DEPARTMENT
 HIRA thR
 D MANIKANDAN
 GOVT. OF INDIA
 DURAISAMY
 16/07/1986
 Permanent Account Number
 BNZPM2501F
 D manliamolown
 Signature
 04082011

 **Block detected Text 2**

  Sirerabe famint
  FIRA TROR
  INCOME TAX DEPARTMENT
  GOVT, OF INDIA
  ANJANA KUMARI
  KRISHAN KEWAL MUNJAL
  12/08/1978
  Parmanuit Account Numbot
  ALMPK0554A
  19 o.
  Galat
  signature

Here is code for finding first name and last name: Here lines array are block detected text converted into array.

   var lines: [String] = []
            detectedText.enumerateLines { textLine, _ in
                lines.append(textLine)
            }
            print(lines)

    for (key, value) in lines.enumerated() {
                print("i:::", value)
                if self.validatePANCardNumber(value) == true {

                    print("pan card:::", value)

                }
                if self.validateDOB(value) == true {
                    print("dob pan:::", value)
                }

                if value.contains("/ Name") {

                   print("Item \(key + 1):value: \(lines[key + 1])")
                   let f_name = lines[key + 1]
                   print("first Name::", f_name)

                }

                if value.contains("/ Father's Name") {

                    print("Item \(key + 1):value: \(lines[key + 1])")
                    let last_name = lines[key + 1]
                    print("last Name::", last_name)

                }


            }

How to parse first name and last name in correct field ?

Any help much appreciated pls..

PvDev
  • 791
  • 21
  • 67
  • Not exactly an answer to this question, but a simple way to read the data from a PAN card would be to use BlinkID SDK which does it out of the box. Here's a link to the SDK: https://github.com/BlinkID/blinkid-ios – Cerovec Apr 05 '20 at 21:04

0 Answers0