From 4cd769dfdf1133b61935f042e3897c3980f6327b Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 17 Nov 2015 14:37:47 +0100 Subject: Concurrency Problem iwith static StringBuilder --- .../egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java index 7388090c..e29766d8 100644 --- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java +++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java @@ -50,16 +50,12 @@ public class TableDrawUtils { public static final String TABLE_DEBUG = "debug.table"; - private static StringBuilder alternateTableCaption; - public static void drawTable(PDPage page, PDPageContentStream contentStream, float x, float y, float width, float height, PDFBoxTable abstractTable, PDDocument doc, boolean subtable, PDResources formResources, Map images, ISettings settings, IDGenerator generator, PDFAsVisualSignatureProperties properties) throws PdfAsException { - - alternateTableCaption = new StringBuilder(); logger.debug("Drawing Table: X {} Y {} WIDTH {} HEIGHT {} \n{}", x, y, width, height, abstractTable.getOrigTable().toString()); @@ -87,7 +83,7 @@ public class TableDrawUtils { float contenty = y + height; float padding = abstractTable.getPadding(); float[] colsSizes = getColSizes(abstractTable); - + StringBuilder alternateTableCaption = new StringBuilder(); for (int i = 0; i < abstractTable.getRowCount(); i++) { ArrayList row = abstractTable.getRow(i); for (int j = 0; j < row.size(); j++) { @@ -118,13 +114,13 @@ public class TableDrawUtils { drawCaption(page, contentStream, contentx, contenty, colWidth, abstractTable.getRowHeights()[i], padding, abstractTable, doc, cell, formResources, settings); - addToAlternateTableCaption(cell); + addToAlternateTableCaption(cell, alternateTableCaption); break; case Entry.TYPE_VALUE: drawValue(page, contentStream, contentx, contenty, colWidth, abstractTable.getRowHeights()[i], padding, abstractTable, doc, cell, formResources, settings); - addToAlternateTableCaption(cell); + addToAlternateTableCaption(cell, alternateTableCaption); break; case Entry.TYPE_IMAGE: drawImage(page, contentStream, contentx, contenty, @@ -600,7 +596,7 @@ public class TableDrawUtils { return ""; } - private static void addToAlternateTableCaption(Entry cell){ + private static void addToAlternateTableCaption(Entry cell, StringBuilder alternateTableCaption){ alternateTableCaption.append(cell.getValue()); alternateTableCaption.append("\n");//better for screen reader } -- cgit v1.2.3