@@ -504,9 +504,10 @@ else if (defaultOverlayPage != null)
504504 // Note that this segment is only the second best solution to the problem. The best
505505 // would be to make appropriate transforms in calculateAffineTransform()
506506 PDPage page = inputPDFDocument .getPage (pageNumber - 1 );
507- if (page .getRotation () != 0 )
507+ int rotation = page .getRotation ();
508+ if (rotation != 0 )
508509 {
509- return createAdjustedLayoutPage (page );
510+ return createAdjustedLayoutPage (rotation );
510511 }
511512 }
512513 }
@@ -518,16 +519,16 @@ else if (useAllOverlayPages)
518519 return layoutPage ;
519520 }
520521
521- private LayoutPage createAdjustedLayoutPage (PDPage page ) throws IOException
522+ private LayoutPage createAdjustedLayoutPage (int rotation ) throws IOException
522523 {
523- LayoutPage rotatedLayoutPage = rotatedDefaultOverlayPagesMap .get (page . getRotation () );
524+ LayoutPage rotatedLayoutPage = rotatedDefaultOverlayPagesMap .get (rotation );
524525 if (rotatedLayoutPage == null )
525526 {
526527 // createLayoutPage must be called because we can't reuse the COSStream
527528 rotatedLayoutPage = createLayoutPage (defaultOverlayDocument .getPage (0 ));
528- int newRotation = (rotatedLayoutPage .overlayRotation - page . getRotation () + 360 ) % 360 ;
529+ int newRotation = (rotatedLayoutPage .overlayRotation - rotation + 360 ) % 360 ;
529530 rotatedLayoutPage .overlayRotation = newRotation ;
530- rotatedDefaultOverlayPagesMap .put (page . getRotation () , rotatedLayoutPage );
531+ rotatedDefaultOverlayPagesMap .put (rotation , rotatedLayoutPage );
531532 }
532533 return rotatedLayoutPage ;
533534 }
0 commit comments