aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox/src/main/java/at/gv
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-05-22 08:59:04 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2015-05-22 08:59:04 +0200
commit07a9ceecac85c3c0f329285ae113bfdd5f2971bd (patch)
tree0570b707d98d1664ccf1829babb38a87e2ac750c /pdf-as-pdfbox/src/main/java/at/gv
parentf933114e2cfd9e34f6e41e6548bee633169c867d (diff)
downloadpdf-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')
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/PDFBOXObject.java9
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java1
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/FontInfoCache.java1
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsTemplateCreator.java4
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java4
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java7
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxFont.java48
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java45
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxStamper.java2
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxVisualObject.java12
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/TableDrawUtils.java6
11 files changed, 78 insertions, 61 deletions
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/PDFBOXObject.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/PDFBOXObject.java
index f80df075..ef4c055c 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/PDFBOXObject.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/PDFBOXObject.java
@@ -1,10 +1,13 @@
package at.gv.egiz.pdfas.lib.impl.pdfbox;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import javax.activation.DataSource;
import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.font.PDFont;
import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
@@ -13,6 +16,8 @@ public class PDFBOXObject extends PDFObject {
private PDDocument doc;
+ private Map<String, PDFont> fontCache = new HashMap<String, PDFont>();
+
public PDFBOXObject(OperationStatus operationStatus) {
super(operationStatus);
}
@@ -56,4 +61,8 @@ public class PDFBOXObject extends PDFObject {
public String getPDFVersion() {
return String.valueOf(getDocument().getDocument().getVersion());
}
+
+ public Map<String, PDFont> getFontCache() {
+ return fontCache;
+ }
}
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
index 8095911d..cacd39c0 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
@@ -53,7 +53,6 @@ import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageNode;
import org.apache.pdfbox.pdmodel.PDResources;
import org.apache.pdfbox.pdmodel.common.PDNumberTreeNode;
-import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDAttributeObject;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot;
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/FontInfoCache.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/FontInfoCache.java
index 10a5c9f8..3f85e445 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/FontInfoCache.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/FontInfoCache.java
@@ -4,4 +4,5 @@ public class FontInfoCache {
String filename;
String fontName;
String fontFamily;
+ String fontPath;
}
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsTemplateCreator.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsTemplateCreator.java
index 8e03c4d4..0ceb6139 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsTemplateCreator.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsTemplateCreator.java
@@ -55,7 +55,7 @@ public class PDFAsTemplateCreator extends PDFTemplateCreator {
}
- public InputStream buildPDF(PDFAsVisualSignatureDesigner properties)
+ public InputStream buildPDF(PDFAsVisualSignatureDesigner properties, PDDocument originalDocument)
throws IOException, PdfAsException {
logger.debug("pdf building has been started");
PDFTemplateStructure pdfStructure = pdfBuilder.getStructure();
@@ -108,7 +108,7 @@ public class PDFAsTemplateCreator extends PDFTemplateCreator {
properties.getRotation() + properties.getPageRotation());
// inner formstream, form and resource (hlder form containts inner form)
- this.pdfBuilder.createInnerFormStreamPdfAs(template);
+ this.pdfBuilder.createInnerFormStreamPdfAs(template, originalDocument);
this.pdfBuilder.createInnerFormResource();
PDResources innerFormResource = pdfStructure.getInnerFormResources();
this.pdfBuilder.createInnerForm(innerFormResource, pdfStructure.getInnterFormStream(), formater);
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java
index 33e4102d..cd3d1899 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java
@@ -241,7 +241,7 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder implements
}
}
- public void createInnerFormStreamPdfAs(PDDocument template)
+ public void createInnerFormStreamPdfAs(PDDocument template, PDDocument origDoc)
throws PdfAsException {
try {
@@ -332,7 +332,7 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder implements
appendRawCommands(getStructure().getHolderFormStream()
.createOutputStream(), holderFormComment.trim().replace("\n", "").replace("\r", ""));
appendRawCommands(getStructure().getInnterFormStream()
- .createOutputStream(), innerFormComment.trim().replace("\n", "").replace("\r", ""));
+ .createOutputStream(), innerFormComment/*.trim().replace("\n", "").replace("\r", "")*/);
// appendRawCommands(getStructure().getImageFormStream().createOutputStream(),
// imgFormComment);
logger.debug("Injected apereance stream to pdf");
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java
index 3fdc6b4c..0b00cac1 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java
@@ -28,7 +28,6 @@ import java.util.List;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +51,8 @@ public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties {
private float rotationAngle = 0;
+ private PDDocument origDoc;
+
private SignatureProfileSettings signatureProfileSettings;
private String alternativeTableCaption="";
@@ -67,7 +68,7 @@ public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties {
}
this.rotationAngle = pos.getRotation();
try {
- PDDocument origDoc = object.getDocument();
+ origDoc = object.getDocument();
designer = new PDFAsVisualSignatureDesigner(origDoc, pos.getPage(), this, pos.isMakeNewPage());
List<?> pages = origDoc.getDocumentCatalog().getAllPages();
@@ -113,7 +114,7 @@ public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties {
PDFAsVisualSignatureBuilder builder = new PDFAsVisualSignatureBuilder(this, this.settings, designer);
PDFAsTemplateCreator creator = new PDFAsTemplateCreator(builder);
try {
- setVisibleSignature(creator.buildPDF(designer));
+ setVisibleSignature(creator.buildPDF(designer, this.origDoc));
} catch (PdfAsException e) {
throw new PdfAsWrappedIOException(e);
}
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxFont.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxFont.java
index fdbf40e2..05c7eb2a 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxFont.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxFont.java
@@ -40,7 +40,6 @@ import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSObject;
-import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
@@ -48,6 +47,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.settings.ISettings;
+import at.gv.egiz.pdfas.lib.impl.pdfbox.PDFBOXObject;
public class PDFBoxFont {
@@ -94,7 +94,6 @@ public class PDFBoxFont {
float fontSize;
String fontDesc;
String ttfFontDesc;
- PDDocument doc;
ISettings settings;
private FontInfoCache getFontInfo(String pathName) {
@@ -128,6 +127,7 @@ public class PDFBoxFont {
fontInfo.filename = pathName;
fontInfo.fontFamily = fontFamilyToLoad;
fontInfo.fontName = fontNameToLoad;
+ fontInfo.fontPath = pathName;
fontInfoCache.put(pathName, fontInfo);
return fontInfo;
} catch (Throwable e) {
@@ -138,9 +138,13 @@ public class PDFBoxFont {
}
}
- private PDFont findCachedFont(PDDocument doc, FontInfoCache fontInfo) {
+ private PDFont findCachedFont(PDFBOXObject pdfObject, FontInfoCache fontInfo) {
try {
- List<COSObject> cosObjects = doc.getDocument().getObjectsByType(
+ if(pdfObject.getFontCache().containsKey(fontInfo.fontPath)) {
+ return pdfObject.getFontCache().get(fontInfo.fontPath);
+ }
+
+ List<COSObject> cosObjects = pdfObject.getDocument().getDocument().getObjectsByType(
COSName.FONT);
//COSName cosFontName = COSName.getPDFName(fontInfo.fontName);
@@ -182,17 +186,17 @@ public class PDFBoxFont {
return null;
}
- private PDFont generateTTF(String fonttype, PDDocument doc)
+ private PDFont generateTTF(String fonttype, PDFBOXObject pdfObject)
throws IOException {
- boolean cacheNow = false;
- if (doc == null) {
+ /*boolean cacheNow = true;
+ if (pdfObject == null) {
if (this.doc == null) {
this.doc = new PDDocument();
}
doc = this.doc;
} else {
cacheNow = true;
- }
+ }*/
ttfFontDesc = fonttype;
String fontName = fonttype.replaceFirst("TTF:", "");
String fontPath = this.settings.getWorkingDirectory() + File.separator
@@ -208,7 +212,7 @@ public class PDFBoxFont {
if(fontInfo != null) {
- PDFont font = findCachedFont(doc, fontInfo);
+ PDFont font = findCachedFont(pdfObject, fontInfo);
if (font != null) {
return font;
@@ -218,7 +222,7 @@ public class PDFBoxFont {
logger.debug("Instantiating font.");
//if (cacheNow) {
- cachedfont = PDTrueTypeFont.loadTTF(doc, fontPath);
+ cachedfont = PDTrueTypeFont.loadTTF(pdfObject.getDocument(), fontPath);
fontStyleMap.put(fontPath, cachedfont);
return cachedfont;
//} else {
@@ -228,10 +232,10 @@ public class PDFBoxFont {
}
private PDFont generateFont(String fonttype, String fontder,
- PDDocument originalDoc) throws IOException {
+ PDFBOXObject pdfObject) throws IOException {
if (fonttype.startsWith("TTF:")) {
// Load TTF Font
- return generateTTF(fonttype, originalDoc);
+ return generateTTF(fonttype, pdfObject);
} else {
if (fontder == null) {
fontder = NORMAL;
@@ -247,15 +251,15 @@ public class PDFBoxFont {
}
}
- private void setFont(String desc, PDDocument originalDoc)
+ private void setFont(String desc, PDFBOXObject pdfObject)
throws IOException {
String[] fontArr = desc.split(",");
if (fontArr.length == 3) {
- font = generateFont(fontArr[0], fontArr[2], originalDoc);
+ font = generateFont(fontArr[0], fontArr[2], pdfObject);
fontSize = Float.parseFloat(fontArr[1]);
} else if (fontArr.length == 2 && fontArr[0].startsWith("TTF:")) {
- font = generateFont(fontArr[0], null, originalDoc);
+ font = generateFont(fontArr[0], null, pdfObject);
fontSize = Float.parseFloat(fontArr[1]);
} else {
logger.warn(
@@ -268,22 +272,24 @@ public class PDFBoxFont {
}
public PDFBoxFont(String fontDesc, ISettings settings,
- PDDocument originalDoc) throws IOException {
+ PDFBOXObject pdfObject) throws IOException {
this.settings = settings;
this.fontDesc = fontDesc;
logger.debug("Creating Font: " + fontDesc);
- this.setFont(fontDesc, originalDoc);
+ this.setFont(fontDesc, pdfObject);
}
- public PDFont getFont(PDDocument doc) throws IOException {
+ public PDFont getFont(/*PDFBOXObject pdfObject*/) throws IOException {
if (cachedfont != null) {
return cachedfont;
}
- if (font instanceof PDTrueTypeFont && doc != null) {
- return generateTTF(ttfFontDesc, doc);
+ return font;
+ /*
+ if (font instanceof PDTrueTypeFont && pdfObject != null) {
+ return generateTTF(ttfFontDesc, pdfObject);
} else {
return font;
- }
+ }*/
}
public float getFontSize() {
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();
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxStamper.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxStamper.java
index 3dd1f0a4..6d1fccff 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxStamper.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxStamper.java
@@ -48,7 +48,7 @@ public class PdfBoxStamper implements IPDFStamper {
public IPDFVisualObject createVisualPDFObject(PDFObject pdf, Table table) throws IOException {
try {
PDFBOXObject pdfboxObject = (PDFBOXObject)pdf;
- return new PdfBoxVisualObject(table, pdf.getStatus().getSettings(), pdfboxObject.getDocument());
+ return new PdfBoxVisualObject(table, pdf.getStatus().getSettings(), pdfboxObject);
} catch (PdfAsException e) {
throw new PdfAsWrappedIOException(e);
}
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxVisualObject.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxVisualObject.java
index 9fd8ed84..feacf3d1 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxVisualObject.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PdfBoxVisualObject.java
@@ -25,12 +25,12 @@ package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox;
import java.io.IOException;
-import org.apache.pdfbox.pdmodel.PDDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.settings.ISettings;
+import at.gv.egiz.pdfas.lib.impl.pdfbox.PDFBOXObject;
import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
import at.knowcenter.wag.egov.egiz.table.Table;
@@ -46,13 +46,13 @@ public class PdfBoxVisualObject implements IPDFVisualObject {
private float y;
private int page;
private ISettings settings;
- private PDDocument originalDoc;
+ private PDFBOXObject pdfBoxObject;
- public PdfBoxVisualObject(Table table, ISettings settings, PDDocument originalDoc)
+ public PdfBoxVisualObject(Table table, ISettings settings, PDFBOXObject pdfBoxObject)
throws IOException, PdfAsException {
this.abstractTable = table;
- this.originalDoc = originalDoc;
- this.table = new PDFBoxTable(table, null, settings, originalDoc);
+ this.pdfBoxObject = pdfBoxObject;
+ this.table = new PDFBoxTable(table, null, settings, pdfBoxObject);
this.settings = settings;
}
@@ -62,7 +62,7 @@ public class PdfBoxVisualObject implements IPDFVisualObject {
public void fixWidth() {
try {
- table = new PDFBoxTable(abstractTable, null, this.width, settings, this.originalDoc);
+ table = new PDFBoxTable(abstractTable, null, this.width, settings, this.pdfBoxObject);
} catch (IOException e) {
logger.warn("Failed to fix width of Table!", e);
} catch (PdfAsException e) {
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 9b0f5ae1..7388090c 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
@@ -24,7 +24,6 @@
package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox;
import java.awt.Color;
-import java.beans.DesignMode;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -41,7 +40,6 @@ import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.impl.signing.pdfbox.PADESPDFBOXSigner;
import at.knowcenter.wag.egov.egiz.table.Entry;
import at.knowcenter.wag.egov.egiz.table.Style;
@@ -278,7 +276,7 @@ public class TableDrawUtils {
float fontSize = PDFBoxFont.defaultFontSize;
PDFont textFont = PDFBoxFont.defaultFont;
- textFont = abstractTable.getFont().getFont(doc);
+ textFont = abstractTable.getFont().getFont();//doc);
fontSize = abstractTable.getFont().getFontSize();
// get the cell Text
@@ -312,7 +310,7 @@ public class TableDrawUtils {
float fontSize = PDFBoxFont.defaultFontSize;
PDFont textFont = PDFBoxFont.defaultFont;
- textFont = abstractTable.getValueFont().getFont(doc);
+ textFont = abstractTable.getValueFont().getFont();//doc);
fontSize = abstractTable.getValueFont().getFontSize();
// get the cell Text