diff --git a/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/AnnotationProperties.java b/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/AnnotationProperties.java index 583cdfe4..1b7f1f0d 100644 --- a/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/AnnotationProperties.java +++ b/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/AnnotationProperties.java @@ -322,7 +322,7 @@ public void setEndPoint(Point endPoint) { } public Form getNormalAppereance() { - return getProperty(AnnotationConsts.NORM_APPEARANCE, new Form(new Content()), Form.class); + return getProperty(AnnotationConsts.NORM_APPEARANCE, new Form(new Content(), null), Form.class); } public String getFontFace() { diff --git a/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/FreeTextAnnotationHolder.java b/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/FreeTextAnnotationHolder.java index dba3e834..5374761d 100644 --- a/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/FreeTextAnnotationHolder.java +++ b/Display/JavaViewer/src/main/java/com/datalogics/pdfl/JavaViewer/Document/Annotations/FreeTextAnnotationHolder.java @@ -66,105 +66,6 @@ private void setAutosize() { } } - /** - * Method is used to generate annotation appearance. It uses current font - * face, size, alignment and background and foreground colors of annotation. - * - * @return - new annotation form which constrains from input data - */ - private Form getAnnotationForm() { - Rect dLRect = getProperties().getBoundingRect(); - String annotationText = getProperties().getContents(); - Content content = (getProperties().getNormalAppereance() != null) ? getProperties().getNormalAppereance().getContent() : new Content(); - GraphicState gs = new GraphicState(); - Path path = new Path(); - EnumSet pathPaintOpFlag; - - if (gs.getStrokeColor() != null) { - gs.setStrokeColor(Utils.transform(getProperties().getForeColor())); - pathPaintOpFlag = path.getPaintOp(); - pathPaintOpFlag.add(PathPaintOpFlags.STROKE); - path.setPaintOp(pathPaintOpFlag); - } - if (getProperties().hasFill()) { - gs.setFillColor(Utils.transform(getProperties().getInteriorColor())); - pathPaintOpFlag = path.getPaintOp(); - pathPaintOpFlag.add(PathPaintOpFlags.FILL); - path.setPaintOp(pathPaintOpFlag); - } - - // get the properties for the text - GraphicState gsTextRun = new GraphicState(); - gsTextRun.setFillColor(Utils.transform(getProperties().getForeColor())); - TextState textState = new TextState(); - textState.setFontSize(getProperties().getFontSize()); - - com.datalogics.PDFL.Matrix matrix = new com.datalogics.PDFL.Matrix(); - matrix.setH(dLRect.getLeft()); - matrix.setV(dLRect.getTop() - (textState.getFontSize() * 0.85)); // not the right formula but "close enough" - - double textWidth = dLRect.getRight() - dLRect.getLeft(); - - // get the font - com.datalogics.PDFL.Font dLFont = initFont(); - TextRun textRun = null; - Text text = new Text(); - - int i = 0; - - double maxTextHeight = 0; - // grab the text from the Rich Textbox and add it to the text that will - // be used - // to create the FreeText Annotation - if (annotationText != null) { - String[] chars = annotationText.split("\n"); - while (i < chars.length) { - if (chars.length > 0) { - if (getProperties().getQuadding() == HorizontalAlignment.LEFT) - matrix.setH(matrix.getH() + 2.0 * (gs.getWidth())); - try { - textRun = new TextRun(chars[i], dLFont, gsTextRun, textState, matrix); - } catch (Exception MissingCMapException) { - if (MissingCMapException.getMessage().contains("537067605")) { - Font tempFont = new com.datalogics.PDFL.Font("Helvetica"); - textRun = new TextRun(chars[i], tempFont, gsTextRun, textState, matrix); - } - } - - double advance = textRun.getAdvance(); - double align = textWidth - advance; - - maxTextHeight += textRun.getBoundingBox().getHeight(); - if (getProperties().getQuadding() == HorizontalAlignment.RIGHT) { - matrix.setH(matrix.getH() + align); - textRun = new TextRun(chars[i], dLFont, gsTextRun, textState, matrix); - } else if (getProperties().getQuadding() == HorizontalAlignment.CENTER) { - matrix.setH(matrix.getH() + (align / 2.0)); - textRun = new TextRun(chars[i], dLFont, gsTextRun, textState, matrix); - } - - matrix.setH(dLRect.getLeft()); - text.addRun(textRun); - } - matrix.setV(matrix.getV() - 1.2 * textState.getFontSize()); - i++; - } - } - - // create content to save the new annotation to - content = new Content(); - path.setGraphicState(gs); - // adjust the rectangle so it does not clip the text - double width = dLRect.getRight() - dLRect.getLeft(); - double height = dLRect.getTop() - dLRect.getBottom(); - - path.addRect(new Point(dLRect.getLeft(), dLRect.getBottom()), width, height); - content.addElement(path); - content.addElement(text); - - return new Form(content); // create a new form and return it - } - /** * Method is used to update FreeTextAnnotation's appearance. It sets font * face, font size, font alignment and foreground and background colors of