get pdf text in swift

387 views Asked by At

i try with no success to get the text from a pdf page.

i try :

CGPDFOperatorTableSetCallback(operatorTableRef!, "ET") { (scanner, info) in
  var val:UnsafePointer<Int8>?
  let ret=CGPDFScannerPopName(scanner, &val)
  print("ET : \(val) (\(ret)) \(scanner)")
}

let page = document?.page(at: 1)
let stream = CGPDFContentStreamCreateWithPage(page!)
let scanner = CGPDFScannerCreate(stream, operatorTableRef, nil)
CGPDFScannerScan(scanner)
CGPDFScannerRelease(scanner)        
CGPDFContentStreamRelease(stream)

i try 'ET', 'BT', ... the callback is fired, but val is always to 'nil' i just want to get all text on page.

thanks...

0

There are 0 answers