0

I'm developing an application that use Icepdf to show a pdf and draw something upon it.

I have a square annotation floating over the page but i have a nasty issue. If i change page and come back to the page where the annotation is visible, if i move the annotation by dragging it the content of the page disappear becoming completely blank. This is the portion of code i use to show the moving annotation on top of the pdf.

Probably I'm missing something or doing it in wrong way.

controller.setAnnotationPanel(null);
controller.setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_SELECTION);      controller.getDocumentViewController().setViewCursor(DocumentViewController.CURSOR_SELECT);
Rectangle bbox = new Rectangle((int) (getPageWidth(getLastPage()) - SIGN_BOX_WIDTH - SIGN_BOX_MARGIN), SIGN_BOX_MARGIN, SIGN_BOX_WIDTH, SIGN_BOX_HEIGHT);
int index = getLastPage() - 1;
Document document = controller.getDocument();
DocumentViewModel documentViewModel=controller.getDocumentViewController().getDocumentViewModel();
PageTree pageTree = document.getPageTree();
Page page = pageTree.getPage(index);
// create and init the page's annotation components. [b]
java.util.List<AbstractPageViewComponent> pageComponents=controller.getDocumentViewController().getDocumentViewModel().getPageComponents();
AbstractPageViewComponent pageViewComponent = pageComponents.get(getLastPage() - 1);

tsq = (SquareAnnotation) AnnotationFactory.buildAnnotation(controller.getDocument().getPageTree().getLibrary(),Annotation.SUBTYPE_SQUARE,bbox);
BorderStyle bs = new BorderStyle();
bs.setBorderStyle(BorderStyle.BORDER_STYLE_SOLID);
bs.setStrokeWidth(2.0f);
tsq.setColor(Color.red);
tsq.setBorderStyle(bs);
tsq.setBBox(bbox);
tsq.setRectangle(bbox);
AffineTransform at = controller.getDocument().getPageTree().getPage(getLastPage() - 1).getPageTransform(controller.getDocumentViewController().getDocumentViewModel().getPageBoundary(), controller.getUserRotation(), controller.getUserZoom());
tsq.resetAppearanceStream(at);

SquareAnnotationComponent annotationComponent= (SquareAnnotationComponent) AnnotationComponentFactory.buildAnnotationComponent(tsq,controller.getDocumentViewController(),pageViewComponent,controller.getDocumentViewController().getDocumentViewModel());
annoCB.setCurrentAnnotation(annotationComponent);
controller.getDocument().getPageTree().getPage(getLastPage() - 1).addAnnotation(tsq);

Please assist to solve.

4

1 回答 1

0

我不得不解决这个问题,没有真正的线索可以解决。

于 2016-01-28T09:06:42.683 回答