From 9aeff8ada5f67086f87f90aa9d61beb6194e93aa Mon Sep 17 00:00:00 2001 From: pdanner Date: Thu, 17 Feb 2011 15:16:34 +0000 Subject: fixed link overlay text pos git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@762 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/StructContentHelper.java | 45 +++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java index a754b8e..859d2c0 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java @@ -75,9 +75,9 @@ public class StructContentHelper implements StructContentWriter { */ private Rectangle tempMarkedPos = null; /** - * Position of the signature verify link overlay + * Cell position of the signature verify link overlay */ - private Rectangle verifyLinkPos = null; + private Rectangle verifyLinkCellPos = null; /** * Kids array (K) of the StructTreeRoot @@ -410,7 +410,7 @@ public class StructContentHelper implements StructContentWriter { * Implements {@link StructContentWriter#storeCurrentPosAsLink()} */ public void storeCurrentPosAsLink() { - this.verifyLinkPos = new Rectangle(this.tempMarkedPos); + this.verifyLinkCellPos = new Rectangle(this.tempMarkedPos); } private Map tmpMap = new HashMap(); @@ -463,7 +463,7 @@ public class StructContentHelper implements StructContentWriter { // iText "converts" 0.0f to an integer, therefore we cannot use 0, not nice... //linkAnnot.put(PdfName.RECT, new PdfArray(new float[] {0.01f, 0.01f, 0.01f, 0.01f})); // take cell pos as link pos - linkAnnot.put(PdfName.RECT, new PdfArray(calcLinkPos(atp, this.verifyLinkPos))); + linkAnnot.put(PdfName.RECT, new PdfArray(calcLinkPos(atp))); linkAnnot.put(PdfName.STRUCTPARENT, structParentNr); linkAnnot.put(PdfName.SUBTYPE, PdfName.LINK); @@ -472,25 +472,26 @@ public class StructContentHelper implements StructContentWriter { } - private PdfArray calcLinkPos(ActualTablePos atp, Rectangle pos) { + private PdfArray calcLinkPos(ActualTablePos atp) { PdfArray res = new PdfArray(); - float downY = atp.y - atp.height + pos.getTop() - pos.getHeight(); - - float startX = atp.x + pos.getLeft(); - float yLine = getPosMapVal("yLine"); - float lineHigh = getPosMapVal("maxSize");; - float lineWidth = getPosMapVal("lineWidth"); - UrlInTextFinder finder = (UrlInTextFinder) this.linkPosMap.get("urlFinder"); - - // maybe one could calc the link pos even more exactly with char with counting - // but this should be close enough (see BidiLine.processLine and chung.getcharwith) - float lineCorr = -2; - float xCorr = 2; - res.add(new PdfNumber(xCorr +startX + finder.calcLinkPosXStart(lineWidth))); - res.add(new PdfNumber(downY + yLine + lineHigh + lineCorr)); - res.add(new PdfNumber(xCorr + startX + finder.calcLinkPosXEnd(lineWidth))); - res.add(new PdfNumber(downY + yLine + lineCorr)); - + + float downY = atp.y - atp.height; + + float startX = atp.x + this.verifyLinkCellPos.getLeft(); + float yLine = getPosMapVal("yLine"); + float lineHigh = getPosMapVal("maxSize"); + float lineWidth = getPosMapVal("lineWidth"); + UrlInTextFinder finder = (UrlInTextFinder) this.linkPosMap.get("urlFinder"); + + // maybe one could calc the link pos even more exactly with char width counting + // but this should be close enough (see BidiLine.processLine and chunk.getcharwith) + float lineCorr = -2; + float xCorr = 5; + res.add(new PdfNumber(1 + startX + finder.calcLinkPosXStart(lineWidth))); + res.add(new PdfNumber(downY + yLine + lineHigh + lineCorr)); + res.add(new PdfNumber(xCorr + startX + finder.calcLinkPosXEnd(lineWidth))); + res.add(new PdfNumber(downY + yLine + lineCorr)); + return res; } -- cgit v1.2.3