aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java14
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java18
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java68
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java22
4 files changed, 115 insertions, 7 deletions
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java
index 0eee4cd3..e380e483 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java
@@ -9,6 +9,7 @@ import javax.activation.DataSource;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.font.PDFont;
+import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.PDFAsFontCache;
import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
@@ -18,6 +19,16 @@ public class PDFBOXObject extends PDFObject {
private Map<String, PDFont> fontCache = new HashMap<String, PDFont>();
+ private PDFAsFontCache sigBlockFontCache = new PDFAsFontCache();
+
+ public PDFAsFontCache getSigBlockFontCache() {
+ return sigBlockFontCache;
+ }
+
+ public void setSigBlockFontCache(PDFAsFontCache sigBlockFontCache) {
+ this.sigBlockFontCache = sigBlockFontCache;
+ }
+
public PDFBOXObject(OperationStatus operationStatus) {
super(operationStatus);
}
@@ -64,7 +75,4 @@ public class PDFBOXObject extends PDFObject {
return String.valueOf(getDocument().getDocument().getVersion());
}
- public Map<String, PDFont> getFontCache() {
- return fontCache;
- }
}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
index 429fe518..0966ba11 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
@@ -25,6 +25,7 @@ package at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
+import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
@@ -32,6 +33,7 @@ import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.lib.impl.pdfbox2.utils.PdfBoxUtils;
import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
@@ -263,11 +265,19 @@ public class Positioning {
// Now we have to getfreespace in page and reguard footerline
float footer_line = pos.getFooterLine();
- float pre_page_length = PDFUtilities.calculatePageLength(pdfDataSource,
- page - 1, page_height - footer_line, /* page_rotation, */
- legacy32, legacy40);
+// float pre_page_length = PDFUtilities.calculatePageLength(pdfDataSource,
+// page - 1, page_height - footer_line, /* page_rotation, */
+// legacy32, legacy40);
- if (pre_page_length == Float.NEGATIVE_INFINITY) {
+ float pre_page_length = Float.NEGATIVE_INFINITY;
+ try {
+ pre_page_length = PDFUtilities.getMaxYPosition(pdfDataSource, page-1, pdf_table, SIGNATURE_MARGIN_VERTICAL, footer_line);
+ //pre_page_length = PDFUtilities.getFreeTablePosition(pdfDataSource, page-1, pdf_table,SIGNATURE_MARGIN_VERTICAL);
+ } catch (IOException e) {
+ logger.warn("Could not determine page length, using -INFINITY");
+ }
+
+ if (pre_page_length == Float.NEGATIVE_INFINITY){
// we do have an empty page or nothing in area above footerline
pre_page_length = page_height;
// no text --> SIGNATURE_BORDER
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java
new file mode 100644
index 00000000..72c333b7
--- /dev/null
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java
@@ -0,0 +1,68 @@
+package at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning;
+
+import java.awt.Color;
+import java.awt.Paint;
+import java.io.IOException;
+
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import org.apache.pdfbox.rendering.PageDrawer;
+import org.apache.pdfbox.rendering.PageDrawerParameters;
+
+public class PositioningPageDrawer extends PageDrawer{
+
+ public PositioningPageDrawer(PageDrawerParameters parameters)
+ throws IOException {
+ super(parameters);
+ // TODO Auto-generated constructor stub
+ }
+
+ private static final Color POSCOLOR = new Color(234, 14, 184, 211);
+
+ @Override
+ protected Paint getPaint(PDColor color){
+ return POSCOLOR;
+ }
+
+// @Override
+// protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,Vector displacement) throws IOException{
+// // bbox in EM -> user units
+// Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1);
+// AffineTransform at = textRenderingMatrix.createAffineTransform();
+// bbox = at.createTransformedShape(bbox);
+//
+// // save
+// Graphics2D graphics = getGraphics();
+//
+// // draw
+// graphics.setClip(graphics.getDeviceConfiguration().getBounds());
+// graphics.setColor(POSCOLOR);
+// graphics.setStroke(new BasicStroke(.5f));
+// graphics.draw(bbox);
+//
+// // restore
+// }
+//
+// @Override
+// public void fillPath(int windingRule) throws IOException
+// {
+// // bbox in user units
+// Shape bbox = getLinePath().getBounds2D();
+//
+// // draw path (note that getLinePath() is now reset)
+// //super.fillPath(windingRule);
+//
+// // save
+// Graphics2D graphics = getGraphics();
+//
+//
+// // draw
+// graphics.setClip(graphics.getDeviceConfiguration().getBounds());
+// graphics.setColor(POSCOLOR);
+// graphics.setStroke(new BasicStroke(.5f));
+// graphics.draw(bbox);
+//
+// }
+
+
+
+}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java
new file mode 100644
index 00000000..64e8fd17
--- /dev/null
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java
@@ -0,0 +1,22 @@
+package at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning;
+
+import java.io.IOException;
+
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.rendering.PDFRenderer;
+import org.apache.pdfbox.rendering.PageDrawer;
+import org.apache.pdfbox.rendering.PageDrawerParameters;
+
+public class PositioningRenderer extends PDFRenderer{
+
+ public PositioningRenderer(PDDocument document) {
+ super(document);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected PageDrawer createPageDrawer(PageDrawerParameters params) throws IOException{
+ return new PositioningPageDrawer(params);
+ }
+
+}