Skip to content

Commit

Permalink
Improvements to support for Apache PDFBox TilingPaint.
Browse files Browse the repository at this point in the history
  • Loading branch information
p1xel committed May 29, 2020
1 parent e2a06f7 commit 2e97fe5
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,18 @@ private void applyPatternPaint(Paint paint, PaintApplierState state) throws IOEx
/*
* Apache PDFBox Tiling Paint
*/
private void applyTilingPaint(Paint paint, PaintApplierState state) throws IOException
private void applyTilingPaint(Paint paint, PaintApplierState state)
{
TexturePaint texturePaint = getPrivateFieldValue(paint, "paint");
applyTexturePaint(texturePaint, state);
try
{
Paint tilingPaint = getPrivateFieldValue(paint, "paint");
applyPaint(tilingPaint, state);
}
catch (Exception e)
{
System.err.println("PdfBoxGraphics2DPaintApplier error while drawing Tiling Paint");
e.printStackTrace();
}
}

private void applyComposite(PaintApplierState state)
Expand Down Expand Up @@ -855,14 +863,18 @@ protected static <T> T getPrivateFieldValue(Object obj, String fieldName)
try
{
Class<?> c = obj.getClass();
try
{
Field f = c.getDeclaredField(fieldName);
f.setAccessible(true);
return (T)f.get(obj);
}
catch (NoSuchFieldException ignored)
while (c != null)
{
try
{
Field f = c.getDeclaredField(fieldName);
f.setAccessible(true);
return (T) f.get(obj);
}
catch (NoSuchFieldException ignored)
{
}
c = c.getSuperclass();
}
throw new NullPointerException("Field " + fieldName + " not found!");
}
Expand Down

0 comments on commit 2e97fe5

Please sign in to comment.