本文整理汇总了Java中org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationTextMarkup类的典型用法代码示例。如果您正苦于以下问题:Java PDAnnotationTextMarkup类的具体用法?Java PDAnnotationTextMarkup怎么用?Java PDAnnotationTextMarkup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PDAnnotationTextMarkup类属于org.apache.pdfbox.pdmodel.interactive.annotation包,在下文中一共展示了PDAnnotationTextMarkup类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotatedObjectDrawn
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationTextMarkup; //导入依赖的package包/类
@Override
public void annotatedObjectDrawn(Annotated drawnObject,
DrawContext drawContext, Position upperLeft, float width,
float height) throws IOException {
Iterable<HighlightAnnotation> HighlightAnnotations = drawnObject
.getAnnotationsOfType(HighlightAnnotation.class);
for (HighlightAnnotation highlightAnnotation : HighlightAnnotations) {
// use PDF text markup to implement the highlight
PDAnnotationTextMarkup markup = new PDAnnotationTextMarkup(
PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
// use the bounding box of the drawn object to position the
// highlight
PDRectangle bounds = new PDRectangle();
bounds.setLowerLeftX(upperLeft.getX());
bounds.setLowerLeftY(upperLeft.getY() - height);
bounds.setUpperRightX(upperLeft.getX() + width);
bounds.setUpperRightY(upperLeft.getY() + 1);
markup.setRectangle(bounds);
float[] quadPoints = CompatibilityHelper.toQuadPoints(bounds);
quadPoints = CompatibilityHelper.transformToPageRotation(
quadPoints, drawContext.getCurrentPage());
markup.setQuadPoints(quadPoints);
// set the highlight color if given
if (highlightAnnotation.getColor() != null) {
CompatibilityHelper.setAnnotationColor(markup, highlightAnnotation.getColor());
}
// finally add the markup to the PDF
drawContext.getCurrentPage().getAnnotations().add(markup);
}
}
示例2: nonBlockingAnnotations
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationTextMarkup; //导入依赖的package包/类
private List<PDAnnotation> nonBlockingAnnotations(List<PDAnnotation> annotations) {
//filters out annotations that pdfbox draws poorly so they don't blot the text out and
//make the images hard to see. This includes hightlight textMarkups and Popups
List<PDAnnotation> annotationsThatAreNotTextMarkupOrPopup = new ArrayList<>();
for(PDAnnotation annotation: annotations) {
if (annotation instanceof PDAnnotationTextMarkup) {
if (!PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT.equals(annotation.getSubtype())) {
annotationsThatAreNotTextMarkupOrPopup.add(annotation);
}
}
else if (annotation.getClass() == PDAnnotationMarkup.class || annotation.getClass() == PDAnnotationRubberStamp.class) {
annotationsThatAreNotTextMarkupOrPopup.add(annotation);
}
}
return annotationsThatAreNotTextMarkupOrPopup;
}
示例3: makeNewAnnotation
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationTextMarkup; //导入依赖的package包/类
private PDAnnotationTextMarkup makeNewAnnotation(PDAnnotationTextMarkup comment, PdfComment userComment, String messageWithLink) {
PDAnnotationTextMarkup newComment = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
List<Tag> tags = userComment.getTags();
if (tags.contains(Tag.CONSIDER_FIX) || tags.contains(Tag.POSITIVE)) {
newComment.setColour(GREEN);
} else if (tags.contains(Tag.MUST_FIX)) {
newComment.setColour(ORANGE);
} else {
newComment.setColour(YELLOW);
}
newComment.setContents(messageWithLink);
newComment.setRectangle(comment.getRectangle()); //both rectangle and quadpoints are needed... don't know why
newComment.setQuadPoints(comment.getQuadPoints());
newComment.setSubject(comment.getSubject());
newComment.setTitlePopup(comment.getTitlePopup()); //author name
return newComment;
}
示例4: updateCommentsWithColorsAndLinks
import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationTextMarkup; //导入依赖的package包/类
public void updateCommentsWithColorsAndLinks(List<PdfComment> comments, Repo repo) {
@SuppressWarnings("unchecked")
List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
int commentOn = 0;
for(PDPage page : pages) {
try {
List<PDAnnotation> newList = new ArrayList<PDAnnotation>();
List<PDAnnotation> annotations = page.getAnnotations();
for(int i=0; i<annotations.size(); i++) {
PDAnnotation anno = annotations.get(i);
if (anno instanceof PDAnnotationTextMarkup) {
PdfComment userComment = comments.get(commentOn);
commentOn++;
String newMessage = userComment.getMessageWithLink(repo);
PDAnnotationTextMarkup newComment = makeNewAnnotation((PDAnnotationTextMarkup) anno, userComment, newMessage);
newList.add(newComment);
} else {
newList.add(anno);
}
}
page.setAnnotations(newList);
} catch(IOException e) {
e.printStackTrace();
} finally {
//page.clear();
page.updateLastModified();
}
}
}