Avoid looping through all the page tree if there is no destination page (#3396)
* Avoid looping through all the page tree if there is no destination page Fixes: #3396 Auto-cherry-pick to 1.0.x Signed-off-by: torakiki <andrea.vacondio@gmail.com>
This commit is contained in:
@@ -140,11 +140,13 @@ public class ParagraphManager {
|
||||
return -1;
|
||||
}
|
||||
PDPage currentPage = current.findDestinationPage(this.document);
|
||||
PDPageTree pages = this.document.getDocumentCatalog().getPages();
|
||||
for (int i = 0; i < pages.getCount(); i++) {
|
||||
var page = pages.get(i);
|
||||
if (page.equals(currentPage)) {
|
||||
return i + 1;
|
||||
if (currentPage != null) {
|
||||
PDPageTree pages = this.document.getDocumentCatalog().getPages();
|
||||
for (int i = 0; i < pages.getCount(); i++) {
|
||||
var page = pages.get(i);
|
||||
if (page.equals(currentPage)) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user