@@ -1580,6 +1580,16 @@ public void showAnnotation(PDAnnotation annotation) throws IOException
15801580 }
15811581 if (annotation .isNoRotate () && getCurrentPage ().getRotation () != 0 )
15821582 {
1583+ appearance = annotation .getAppearance ();
1584+ if (appearance != null && appearance .getNormalAppearance () != null &&
1585+ appearance .getNormalAppearance ().isStream () &&
1586+ hasTransparency (appearance .getNormalAppearance ().getAppearanceStream ()))
1587+ {
1588+ // PDFBOX-4744: avoid appearances with transparency groups until we have fixed
1589+ // the rendering. A real solution should probably be
1590+ // in PDFStreamEngine.processAnnotation().
1591+ annotation .constructAppearances ();
1592+ }
15831593 PDRectangle rect = annotation .getRectangle ();
15841594 AffineTransform savedTransform = graphics .getTransform ();
15851595 // "The upper-left corner of the annotation remains at the same point in
@@ -1588,13 +1598,40 @@ public void showAnnotation(PDAnnotation annotation) throws IOException
15881598 rect .getLowerLeftX (), rect .getUpperRightY ());
15891599 super .showAnnotation (annotation );
15901600 graphics .setTransform (savedTransform );
1601+ annotation .setAppearance (appearance ); // restore
15911602 }
15921603 else
15931604 {
15941605 super .showAnnotation (annotation );
15951606 }
15961607 }
15971608
1609+ private boolean hasTransparency (PDFormXObject form ) throws IOException
1610+ {
1611+ if (form == null )
1612+ {
1613+ return false ;
1614+ }
1615+ PDResources resources = form .getResources ();
1616+ if (resources == null )
1617+ {
1618+ return false ;
1619+ }
1620+ for (COSName name : resources .getXObjectNames ())
1621+ {
1622+ PDXObject xObject = resources .getXObject (name );
1623+ if (xObject instanceof PDTransparencyGroup )
1624+ {
1625+ return true ;
1626+ }
1627+ if (xObject instanceof PDFormXObject && hasTransparency ((PDFormXObject ) xObject ))
1628+ {
1629+ return true ;
1630+ }
1631+ }
1632+ return false ;
1633+ }
1634+
15981635 /**
15991636 * {@inheritDoc}
16001637 */
0 commit comments