File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed 
document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/config Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -140,11 +140,13 @@ private int getPageNumber(PDOutlineItem current) throws IOException {
140140			return  -1 ;
141141		}
142142		PDPage  currentPage  = current .findDestinationPage (this .document );
143- 		PDPageTree  pages  = this .document .getDocumentCatalog ().getPages ();
144- 		for  (int  i  = 0 ; i  < pages .getCount (); i ++) {
145- 			var  page  = pages .get (i );
146- 			if  (page .equals (currentPage )) {
147- 				return  i  + 1 ;
143+ 		if (currentPage  != null ){
144+ 			PDPageTree  pages  = this .document .getDocumentCatalog ().getPages ();
145+ 			for  (int  i  = 0 ; i  < pages .getCount (); i ++) {
146+ 				var  page  = pages .get (i );
147+ 				if  (page .equals (currentPage )) {
148+ 					return  i  + 1 ;
149+ 				}
148150			}
149151		}
150152		return  -1 ;
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments