diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-05-22 08:59:04 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2015-05-22 08:59:04 +0200 |
commit | 07a9ceecac85c3c0f329285ae113bfdd5f2971bd (patch) | |
tree | 0570b707d98d1664ccf1829babb38a87e2ac750c /pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java | |
parent | f933114e2cfd9e34f6e41e6548bee633169c867d (diff) | |
download | pdf-as-4-07a9ceecac85c3c0f329285ae113bfdd5f2971bd.tar.gz pdf-as-4-07a9ceecac85c3c0f329285ae113bfdd5f2971bd.tar.bz2 pdf-as-4-07a9ceecac85c3c0f329285ae113bfdd5f2971bd.zip |
TTF font caching, Import cleanup, auto positioning in rotated pages
Diffstat (limited to 'pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java')
-rw-r--r-- | pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java index 8959d631..d5c5d683 100644 --- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java +++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java @@ -25,8 +25,6 @@ package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox; import java.awt.Color; import java.awt.Dimension; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; @@ -42,6 +40,7 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException; import at.gv.egiz.pdfas.common.settings.ISettings; import at.gv.egiz.pdfas.common.utils.ImageUtils; import at.gv.egiz.pdfas.common.utils.StringUtils; +import at.gv.egiz.pdfas.lib.impl.pdfbox.PDFBOXObject; import at.knowcenter.wag.egov.egiz.table.Entry; import at.knowcenter.wag.egov.egiz.table.Style; import at.knowcenter.wag.egov.egiz.table.Table; @@ -70,6 +69,8 @@ public class PDFBoxTable { PDDocument originalDoc; + PDFBOXObject pdfBoxObject; + private void normalizeContent(Table abstractTable) throws PdfAsException { try { int rows = abstractTable.getRows().size(); @@ -94,7 +95,7 @@ public class PDFBoxTable { } private void initializeStyle(Table abstractTable, PDFBoxTable parent, - PDDocument originalDoc) throws IOException { + PDFBOXObject pdfBoxObject) throws IOException { this.table = abstractTable; try { normalizeContent(abstractTable); @@ -130,7 +131,7 @@ public class PDFBoxTable { + abstractTable.getName()); } - font = new PDFBoxFont(fontString, settings, originalDoc); + font = new PDFBoxFont(fontString, settings, pdfBoxObject); if (vfontString == null && parent != null && parent.style != null) { vfontString = parent.style.getValueFont(); @@ -140,7 +141,7 @@ public class PDFBoxTable { + abstractTable.getName()); } - valueFont = new PDFBoxFont(vfontString, settings, originalDoc); + valueFont = new PDFBoxFont(vfontString, settings, pdfBoxObject); } padding = style.getPadding(); @@ -148,11 +149,12 @@ public class PDFBoxTable { } public PDFBoxTable(Table abstractTable, PDFBoxTable parent, float fixSize, - ISettings settings, PDDocument originalDoc) throws IOException, + ISettings settings, PDFBOXObject pdfBoxObject) throws IOException, PdfAsException { this.settings = settings; - this.originalDoc = originalDoc; - initializeStyle(abstractTable, parent, originalDoc); + this.pdfBoxObject = pdfBoxObject; + this.originalDoc = pdfBoxObject.getDocument(); + initializeStyle(abstractTable, parent, pdfBoxObject); float[] relativSizes = abstractTable.getColsRelativeWith(); if (relativSizes != null) { colWidths = new float[relativSizes.length]; @@ -184,11 +186,12 @@ public class PDFBoxTable { } public PDFBoxTable(Table abstractTable, PDFBoxTable parent, - ISettings settings, PDDocument originalDoc) throws IOException, + ISettings settings, PDFBOXObject pdfBoxObject) throws IOException, PdfAsException { this.settings = settings; - this.originalDoc = originalDoc; - initializeStyle(abstractTable, parent, originalDoc); + this.pdfBoxObject = pdfBoxObject; + this.originalDoc = pdfBoxObject.getDocument(); + initializeStyle(abstractTable, parent, pdfBoxObject); this.calculateWidthHeight(); } @@ -318,10 +321,10 @@ public class PDFBoxTable { float fontSize; String string = (String) cell.getValue(); if (isValue) { - c = valueFont.getFont(null); + c = valueFont.getFont();//null fontSize = valueFont.getFontSize(); } else { - c = font.getFont(null); + c = font.getFont();//null fontSize = font.getFontSize(); } if (string == null) { @@ -350,7 +353,7 @@ public class PDFBoxTable { PDFBoxTable pdfBoxTable = null; if (cell.getValue() instanceof Table) { pdfBoxTable = new PDFBoxTable((Table) cell.getValue(), this, - this.settings, originalDoc); + this.settings, pdfBoxObject); cell.setValue(pdfBoxTable); } else if (cell.getValue() instanceof PDFBoxTable) { pdfBoxTable = (PDFBoxTable) cell.getValue(); @@ -526,10 +529,10 @@ public class PDFBoxTable { float fontSize; String string = (String) cell.getValue(); if (isValue) { - c = valueFont.getFont(null); + c = valueFont.getFont();//null fontSize = valueFont.getFontSize(); } else { - c = font.getFont(null); + c = font.getFont();//null fontSize = font.getFontSize(); } @@ -554,13 +557,13 @@ public class PDFBoxTable { PDFBoxTable pdfBoxTable = null; if (cell.getValue() instanceof Table) { pdfBoxTable = new PDFBoxTable((Table) cell.getValue(), this, - width, this.settings, this.originalDoc); + width, this.settings, this.pdfBoxObject); cell.setValue(pdfBoxTable); } else if (cell.getValue() instanceof PDFBoxTable) { // recreate here beacuse of fixed width! pdfBoxTable = (PDFBoxTable) cell.getValue(); pdfBoxTable = new PDFBoxTable(pdfBoxTable.table, this, width, - this.settings, this.originalDoc); + this.settings, this.pdfBoxObject); cell.setValue(pdfBoxTable); } else { throw new IOException("Failed to build PDFBox Table"); @@ -582,10 +585,10 @@ public class PDFBoxTable { float fontSize; String string = (String) cell.getValue(); if (isValue) { - c = valueFont.getFont(null); + c = valueFont.getFont();//null fontSize = valueFont.getFontSize(); } else { - c = font.getFont(null); + c = font.getFont();//null fontSize = font.getFontSize(); } @@ -611,7 +614,7 @@ public class PDFBoxTable { PDFBoxTable pdfBoxTable = null; if (cell.getValue() instanceof Table) { pdfBoxTable = new PDFBoxTable((Table) cell.getValue(), this, - this.settings, originalDoc); + this.settings, pdfBoxObject); cell.setValue(pdfBoxTable); } else if (cell.getValue() instanceof PDFBoxTable) { pdfBoxTable = (PDFBoxTable) cell.getValue(); |