OSDN Git Service

Add check to prevent PDF scrolling from walking off the end of the document.
authorRandy Baumgarte <randy@fbn.cx>
Fri, 18 Feb 2011 13:03:02 +0000 (08:03 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Thu, 24 Feb 2011 01:01:32 +0000 (20:01 -0500)
src/cx/fbn/nevernote/gui/PDFPreview.java

index 7f09ea0..000eaa9 100644 (file)
@@ -57,9 +57,10 @@ public class PDFPreview {
                PDDocument document = null;\r
                try {\r
                                document = PDDocument.load( filePath );\r
-                               if (document.getNumberOfPages() < pageNumber)\r
+                               if (document.getNumberOfPages() <= pageNumber)\r
+                                       return false;\r
+                               if (document.getDocumentCatalog().getAllPages().size() <= pageNumber)\r
                                        return false;\r
-                               \r
                                PDPage page = (PDPage)document.getDocumentCatalog().getAllPages().get( pageNumber );\r
                                BufferedImage bi = page.convertToImage();\r
                                \r