你可以像这样使用一些循环:
$metaData = $pdf->getDetails(); //Gets PDF metadata
$xtargetTextCoordinate = "12.345" ///////////USE YOUR OWN
$ytargetTextCoordinate = "678.90" ///////////USE YOUR OWN
//Going through each PDF's page...
for ($x=0 ; $x < $metaData['Pages']; $x++ ){
//Reset variables
$streamOfThisPage = [];
$streamOfThisPage = $pdf->getPages()[$x]->getDataTm();
$targetText= "";
//Going through each key element of this page...
foreach($streamOfThisPage as $arrayEle){
if( ($arrayEle[0][4] == $xtargetTextCoordinate ) && ($arrayEle[0][5] == $ytargetTextCoordinate ) ){ //X & Y depend of your document structure...
$targetText = "";
//Remove unecessary data if any
$thisRowWords = explode(" " , $arrayEle[1] );
$referencePeriod = $thisRowWords[0];
foreach($thisRowWords as $position => $word){
$targetText = $targetText . $word . " ";
}
}
}
echo $targetText;