2020import java .awt .geom .PathIterator ;
2121import java .io .IOException ;
2222import java .util .HashSet ;
23+ import java .util .List ;
2324import java .util .Set ;
2425import org .apache .logging .log4j .Logger ;
2526import org .apache .logging .log4j .LogManager ;
2627import org .apache .pdfbox .cos .COSName ;
2728import org .apache .pdfbox .pdmodel .PDAppearanceContentStream ;
2829import org .apache .pdfbox .pdmodel .PDDocument ;
2930import org .apache .pdfbox .pdmodel .common .PDRectangle ;
31+ import org .apache .pdfbox .pdmodel .font .PDType1Font ;
3032import org .apache .pdfbox .pdmodel .font .Standard14Fonts ;
3133import org .apache .pdfbox .pdmodel .font .Standard14Fonts .FontName ;
3234import org .apache .pdfbox .pdmodel .graphics .blend .BlendMode ;
@@ -429,7 +431,10 @@ private void drawStar(PDAnnotationText annotation, final PDAppearanceContentStre
429431 contentStream .setLineCapStyle (0 );
430432 contentStream .setLineWidth (0.59f ); // value from Adobe
431433
432- contentStream .transform (Matrix .getScaleInstance (0.001f * min / 0.8f , 0.001f * min / 0.8f ));
434+ List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
435+ float xScale = (float ) fontMatrix .get (0 );
436+ float yScale = (float ) fontMatrix .get (3 );
437+ contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
433438
434439 // we get the shape of a Zapf Dingbats star (0x2605) and use that one.
435440 // Adobe uses a different font (which one?), or created the shape from scratch.
@@ -453,7 +458,10 @@ private void drawCheck(PDAnnotationText annotation, final PDAppearanceContentStr
453458 contentStream .setLineCapStyle (0 );
454459 contentStream .setLineWidth (0.59f ); // value from Adobe
455460
456- contentStream .transform (Matrix .getScaleInstance (0.001f * min / 0.8f , 0.001f * min / 0.8f ));
461+ List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
462+ float xScale = (float ) fontMatrix .get (0 );
463+ float yScale = (float ) fontMatrix .get (3 );
464+ contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
457465 contentStream .transform (Matrix .getTranslateInstance (0 , 50 ));
458466
459467 // we get the shape of a Zapf Dingbats check (0x2714) and use that one.
@@ -476,7 +484,10 @@ private void drawRightPointer(PDAnnotationText annotation, final PDAppearanceCon
476484 contentStream .setLineCapStyle (0 );
477485 contentStream .setLineWidth (0.59f ); // value from Adobe
478486
479- contentStream .transform (Matrix .getScaleInstance (0.001f * min / 0.8f , 0.001f * min / 0.8f ));
487+ List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
488+ float xScale = (float ) fontMatrix .get (0 );
489+ float yScale = (float ) fontMatrix .get (3 );
490+ contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
480491 contentStream .transform (Matrix .getTranslateInstance (0 , 50 ));
481492
482493 // we get the shape of a Zapf Dingbats right pointer (0x27A4) and use that one.
@@ -577,15 +588,14 @@ private void drawRightArrow(PDAnnotationText annotation, final PDAppearanceConte
577588 contentStream .restoreGraphicsState ();
578589
579590 contentStream .saveGraphicsState ();
580- // rescale so that the glyph fits into circle and move it to circle center
581- // values gathered by trial and error
582- contentStream .transform (Matrix .getScaleInstance (0.001f * min / 1.3f , 0.001f * min / 1.3f ));
583- contentStream .transform (Matrix .getTranslateInstance (200 , 300 ));
584-
585- // we get the shape of a Zapf Dingbats right arrow (0x2794) and use that one.
586- // Adobe uses a different font (which one?), or created the shape from scratch.
587- GeneralPath path = Standard14Fonts .getGlyphPath (FontName .ZAPF_DINGBATS , "a160" );
588- addPath (contentStream , path );
591+ contentStream .moveTo (8 , 17.5f );
592+ contentStream .lineTo (8 , 13.5f );
593+ contentStream .lineTo (3 , 13.5f );
594+ contentStream .lineTo (3 , 6.5f );
595+ contentStream .lineTo (8 , 6.5f );
596+ contentStream .lineTo (8 , 2.5f );
597+ contentStream .lineTo (18 , 10 );
598+ contentStream .closePath ();
589599 contentStream .restoreGraphicsState ();
590600 // surprisingly, this one not counterclockwise.
591601 drawCircle (contentStream , min / 2 , min / 2 , min / 2 - 1 );
0 commit comments