Search code examples
phppdfpdflib

Pdflib to count image Block along with text block in pdfblock


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


Solution

  • 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.