@@ -65,18 +65,22 @@ public void generateNormalAppearance()
6565 annotation .setRectangle (rect );
6666 annotation .getNormalAppearanceStream ().setBBox (new PDRectangle (size , size ));
6767
68- //TODO support Graph, Tag
6968 // test case: pdf_commenting_new.pdf page 7
7069 String attachmentName = annotation .getAttachmentName ();
7170 switch (attachmentName )
7271 {
73- case "PushPin" :
74- drawPushPin (contentStream );
75- break ;
7672 case "Paperclip" :
77- default :
7873 drawPaperclip (contentStream );
7974 break ;
75+ case "Graph" :
76+ drawGraph (contentStream );
77+ break ;
78+ case "Tag" :
79+ drawTag (contentStream );
80+ break ;
81+ default :
82+ drawPushPin (contentStream );
83+ break ;
8084 }
8185 }
8286 catch (IOException e )
@@ -178,6 +182,146 @@ private void drawPushPin(final PDAppearanceContentStream contentStream) throws I
178182 contentStream .fill ();
179183 }
180184
185+ private void drawGraph (final PDAppearanceContentStream contentStream ) throws IOException
186+ {
187+ // ty 18 is from the caller, scale 0.022 is by trial and error
188+ contentStream .transform (new Matrix (0.022f , 0 , 0 , -0.022f , 0f , 18f ));
189+
190+ // Source: https://www.svgrepo.com/svg/339018/chart-histogram
191+ // Author: Carbon Design https://github.com/carbon-design-system/carbon
192+ // License: Apache
193+ contentStream .transform (Matrix .getTranslateInstance (736.04f , 907.89f ));
194+ contentStream .moveTo (0f , 0f );
195+ contentStream .lineTo (-675.23f , 0f );
196+ contentStream .curveTo (-679.72f , 0f , -683.41f , -3.53f , -683.41f , -8.01f );
197+ contentStream .lineTo (-683.41f , -683.37f );
198+ contentStream .lineTo (-667.22f , -683.37f );
199+ contentStream .lineTo (-667.22f , -353.95f );
200+ contentStream .curveTo (-583.85f , -357.8f , -541.53f , -419.99f , -500.49f , -480.27f );
201+ contentStream .curveTo (-459.93f , -539.74f , -418.09f , -601.46f , -337.61f , -601.46f );
202+ contentStream .curveTo (-257.14f , -601.46f , -215.3f , -539.74f , -174.74f , -480.27f );
203+ contentStream .curveTo (-132.58f , -418.07f , -88.81f , -353.79f , 0f , -353.79f );
204+ contentStream .lineTo (0f , -337.6f );
205+ contentStream .curveTo (-97.31f , -337.6f , -143.48f , -405.41f , -188.2f , -471.13f );
206+ contentStream .curveTo (-228.12f , -529.8f , -265.8f , -585.27f , -337.61f , -585.27f );
207+ contentStream .curveTo (-409.43f , -585.27f , -447.11f , -529.8f , -487.03f , -471.13f );
208+ contentStream .curveTo (-530.47f , -407.33f , -575.36f , -341.45f , -667.22f , -337.76f );
209+ contentStream .lineTo (-667.22f , -16.19f );
210+ contentStream .lineTo (-615.76f , -16.19f );
211+ contentStream .lineTo (-615.76f , -255.68f );
212+ contentStream .curveTo (-615.76f , -260.17f , -612.23f , -263.7f , -607.74f , -263.7f );
213+ contentStream .lineTo (-525.82f , -263.7f );
214+ contentStream .lineTo (-525.82f , -345.77f );
215+ contentStream .curveTo (-525.82f , -350.26f , -522.13f , -353.79f , -517.64f , -353.79f );
216+ contentStream .lineTo (-435.73f , -353.79f );
217+ contentStream .lineTo (-435.73f , -458.31f );
218+ contentStream .curveTo (-435.73f , -462.8f , -432.2f , -466.32f , -427.71f , -466.32f );
219+ contentStream .lineTo (-337.61f , -466.32f );
220+ contentStream .curveTo (-333.13f , -466.32f , -329.6f , -462.8f , -329.6f , -458.31f );
221+ contentStream .lineTo (-329.6f , -421.28f );
222+ contentStream .lineTo (-247.68f , -421.28f );
223+ contentStream .curveTo (-243.19f , -421.28f , -239.5f , -417.75f , -239.5f , -413.26f );
224+ contentStream .lineTo (-239.5f , -331.35f );
225+ contentStream .lineTo (-157.58f , -331.35f );
226+ contentStream .curveTo (-153.1f , -331.35f , -149.41f , -327.66f , -149.41f , -323.17f );
227+ contentStream .lineTo (-149.41f , -218.81f );
228+ contentStream .lineTo (-67.49f , -218.81f );
229+ contentStream .curveTo (-63.0f , -218.81f , -59.47f , -215.13f , -59.47f , -210.64f );
230+ contentStream .lineTo (-59.47f , -16.19f );
231+ contentStream .lineTo (0f , -16.19f );
232+ contentStream .lineTo (0f , 0f );
233+ contentStream .closePath ();
234+ contentStream .moveTo (-149.41f , -16.19f );
235+ contentStream .lineTo (-75.67f , -16.19f );
236+ contentStream .lineTo (-75.67f , -202.62f );
237+ contentStream .lineTo (-149.41f , -202.62f );
238+ contentStream .lineTo (-149.41f , -16.19f );
239+ contentStream .closePath ();
240+ contentStream .moveTo (-239.5f , -16.19f );
241+ contentStream .lineTo (-165.76f , -16.19f );
242+ contentStream .lineTo (-165.76f , -315.16f );
243+ contentStream .lineTo (-239.5f , -315.16f );
244+ contentStream .lineTo (-239.5f , -16.19f );
245+ contentStream .closePath ();
246+ contentStream .moveTo (-329.6f , -16.19f );
247+ contentStream .lineTo (-255.7f , -16.19f );
248+ contentStream .lineTo (-255.7f , -405.09f );
249+ contentStream .lineTo (-329.6f , -405.09f );
250+ contentStream .lineTo (-329.6f , -16.19f );
251+ contentStream .closePath ();
252+ contentStream .moveTo (-419.53f , -16.19f );
253+ contentStream .lineTo (-345.79f , -16.19f );
254+ contentStream .lineTo (-345.79f , -450.13f );
255+ contentStream .lineTo (-419.53f , -450.13f );
256+ contentStream .lineTo (-419.53f , -16.19f );
257+ contentStream .closePath ();
258+ contentStream .moveTo (-509.63f , -16.19f );
259+ contentStream .lineTo (-435.73f , -16.19f );
260+ contentStream .lineTo (-435.73f , -337.6f );
261+ contentStream .lineTo (-509.63f , -337.6f );
262+ contentStream .lineTo (-509.63f , -16.19f );
263+ contentStream .closePath ();
264+ contentStream .moveTo (-599.56f , -16.19f );
265+ contentStream .lineTo (-525.82f , -16.19f );
266+ contentStream .lineTo (-525.82f , -247.51f );
267+ contentStream .lineTo (-599.56f , -247.51f );
268+ contentStream .lineTo (-599.56f , -16.19f );
269+ contentStream .closePath ();
270+ contentStream .fill ();
271+ }
272+
273+ private void drawTag (final PDAppearanceContentStream contentStream ) throws IOException
274+ {
275+ // ty 18 is from the caller, scale 0.022 is by trial and error
276+ contentStream .transform (new Matrix (0.022f , 0 , 0 , -0.022f , 0f , 18f ));
277+
278+ // Source: https://www.svgrepo.com/svg/29652/tag
279+ // License: CC0
280+ contentStream .saveGraphicsState ();
281+ contentStream .transform (Matrix .getTranslateInstance (209.26f , 128.32f ));
282+ contentStream .moveTo (0f , 0f );
283+ contentStream .curveTo (-44.73f , 0f , -80.64f , 36.23f , -80.64f , 80.64f );
284+ contentStream .curveTo (-80.64f , 125.2f , -44.57f , 161.27f , 0f , 161.27f );
285+ contentStream .curveTo (44.56f , 161.27f , 80.47f , 125.04f , 80.47f , 80.64f );
286+ contentStream .curveTo (80.63f , 36.07f , 44.56f , 0f , 0f , 0f );
287+ contentStream .closePath ();
288+ contentStream .moveTo (0f , 132.74f );
289+ contentStream .curveTo (-28.7f , 132.74f , -52.1f , 109.33f , -52.1f , 80.64f );
290+ contentStream .curveTo (-52.1f , 51.94f , -28.7f , 28.54f , 0f , 28.54f );
291+ contentStream .curveTo (28.69f , 28.54f , 51.93f , 51.94f , 51.93f , 80.64f );
292+ contentStream .curveTo (51.93f , 109.33f , 28.85f , 132.74f , 0f , 132.74f );
293+ contentStream .closePath ();
294+ contentStream .fill ();
295+ contentStream .restoreGraphicsState ();
296+ contentStream .saveGraphicsState ();
297+ contentStream .transform (Matrix .getTranslateInstance (382.22f , 79.91f ));
298+ contentStream .moveTo (0f , 0f );
299+ contentStream .curveTo (-14.58f , -16.19f , -35.1f , -24.85f , -57.22f , -24.85f );
300+ contentStream .lineTo (-208.23f , -26.45f );
301+ contentStream .curveTo (-240.45f , -26.45f , -271.23f , -14.75f , -293.35f , 8.66f );
302+ contentStream .curveTo (-316.76f , 30.78f , -328.46f , 61.56f , -328.46f , 93.78f );
303+ contentStream .lineTo (-327.02f , 244.95f );
304+ contentStream .curveTo (-325.57f , 265.47f , -318.2f , 285.98f , -302.17f , 302.18f );
305+ contentStream .lineTo (58.68f , 663.02f );
306+ contentStream .lineTo (360.85f , 360.69f );
307+ contentStream .lineTo (0f , 0f );
308+ contentStream .lineTo (0f , 0f );
309+ contentStream .closePath ();
310+ contentStream .moveTo (57.23f , 621.82f );
311+ contentStream .lineTo (-283.09f , 281.5f );
312+ contentStream .curveTo (-293.35f , 271.24f , -299.12f , 258.09f , -299.12f , 243.34f );
313+ contentStream .lineTo (-300.57f , 93.78f );
314+ contentStream .curveTo (-300.57f , 70.38f , -290.31f , 46.81f , -274.12f , 29.34f );
315+ contentStream .curveTo (-256.64f , 11.7f , -233.08f , 1.44f , -208.23f , 1.44f );
316+ contentStream .lineTo (-58.67f , 2.89f );
317+ contentStream .curveTo (-44.08f , 2.89f , -30.77f , 8.66f , -20.51f , 19.08f );
318+ contentStream .lineTo (319.81f , 359.4f );
319+ contentStream .lineTo (57.23f , 621.82f );
320+ contentStream .closePath ();
321+ contentStream .fill ();
322+ contentStream .restoreGraphicsState ();
323+ }
324+
181325 @ Override
182326 public void generateRolloverAppearance ()
183327 {
0 commit comments