Skip to content

Commit

Permalink
New function to return page ID
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Aug 24, 2024
1 parent 80de299 commit 40b4e70
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.11
4.1.0
1 change: 1 addition & 0 deletions src/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public function getPage(int $pid = -1): array
return $this->page[$pid];
}


/**
* Check if the specified page ID exist.
*
Expand Down
10 changes: 10 additions & 0 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ abstract class Settings extends \Com\Tecnick\Pdf\Page\Box
*/
protected int $rootoid = 0;

/**
* Return the current page ID.
*
* @return int Page ID.
*/
public function getPageID(): int
{
return $this->pid;
}

/**
* Sanitize or set the page modification time.
*
Expand Down
3 changes: 3 additions & 0 deletions test/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ public function testAdd(): void
],
];
$this->bcAssertEqualsWithDelta($exp, $res);

$pid = $page->getPageID();
$this->assertEquals(3, $pid);
}

public function testGetNextPage(): void
Expand Down
3 changes: 3 additions & 0 deletions test/RegionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,8 @@ public function testRegionBoundaries(): void
$this->assertFalse($res);
$res = $page->isXOutRegion(141);
$this->assertTrue($res);

$pid = $page->getPageID();
$this->assertEquals(0, $pid);
}
}
8 changes: 8 additions & 0 deletions test/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page
return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, false);
}

public function testGetPageID(): void
{
$page = $this->getTestObject();

$pid = $page->getPageID();
$this->assertEquals(-1, $pid);
}

public function testSanitizePageNumber(): void
{
$page = $this->getTestObject();
Expand Down

0 comments on commit 40b4e70

Please sign in to comment.