Pdflib to count image Block along with text block in pdfblock

145 Views Asked by At

In my pdf Block i have 1 image block and 3 text block. I want to get the count of block as 4 But here

 private function getTotalBlockCount($currentPage) {
    if ( ! isset($currentPage) )
        $currentPage = 0;
    return $this->objPDFLib->pcos_get_number($this->indoc, "length:pages[".$currentPage."]/blocks"); 
}

I am getting only the count as 3. It is counting only text block. How can i get count of image block also

1

There are 1 best solutions below

1
On BEST ANSWER

might It be possible, that you have here a -1 index issue? Please get in mind, the page index for the pcos_get_number() call start at 0. So when you call

private function getTotalBlockCount($currentPage)

with a page number (starting at 1), you might get the number of blocks for the page behind and so you

return $this->objPDFLib->pcos_get_number($this->indoc, 
                 "length:pages[".($currentPage-1)."]/blocks");

might solve your problem.