christian-vigh-phpclasses / PdfToText

Extracts text from PDF files
Other
125 stars 93 forks source link

Extract Data from PDF form Undefined Functions #45

Open dman271828 opened 2 years ago

dman271828 commented 2 years ago

Overall this is the best PdfToText php code I have found. Great code and good job. There are two errors inside the PdfToText.phpclass when I ran the extract form data from pdf example.

Example: /PdfToText-master/examples/formdata-extraction/example.php

Error 1: Undefined function ValidPhpName....

My solution: The ValidPhpName should be member of PdfObjectBase::. However, everywhere in the program it refers to an incorrect class.

Replace all: PdfToTextFormDefinition::ValidPhpName

With: PdfObjectBase::ValidPhpName

Error 2: The GetFormDataFromPdfObject is private error. Old: private function GetFormDataFromPdfObject ( $pdf_data )

Change it to pubic. public function GetFormDataFromPdfObject ( $pdf_data )

This solution worked for me. Here is a portion of the form data output.

OUTPUT:

Form data extraction using an XML definition file (sample.pdf) : object(W9)#27 (20) { ["Name":protected]=> string(6) "ZZNAME" ["BusinessName":protected]=> string(14) "ZZBUSINESSNAME" ["FederalTaxClassification":protected]=> string(1) "6" ["LLCClassification":protected]=> string(1) "C" ["OtherFederalTaxClassification":protected]=> string(1) "7" ["OtherFederalTaxInfo":protected]=> string(7) "ZZOTHER" ["ExemptPayeeCode":protected]=> string(4) "EX01" ["FATCAExemptionCode":protected]=> string(4) "EX02" ["Address":protected]=> string(9) "ZZADDRESS" ["City":protected]=> string(6) "ZZCITY" ["RequesterCoordinates":protected]=> string(28) "ZZREQUESTERNAME address city"