|
@@ -70,109 +70,113 @@ public class CPDFAnnotDatas {
|
|
|
if (cpdfAnnotation == null || !cpdfAnnotation.isValid()){
|
|
|
continue;
|
|
|
}
|
|
|
- CPDFAnnotation.Type type = cpdfAnnotation.getType();
|
|
|
- boolean isArrowLine = true;
|
|
|
- int attrColor = Color.TRANSPARENT;
|
|
|
- String attrTime = "";
|
|
|
- CPDFDate modifyDate = cpdfAnnotation.getRecentlyModifyDate();
|
|
|
- if (null != modifyDate){
|
|
|
- attrTime = CPDFDate.toStandardDate(modifyDate);
|
|
|
+ CPDFAnnotListItem item = convertToListItem(cpdfAnnotation);
|
|
|
+ if (item != null){
|
|
|
+ annotListItems.add(item);
|
|
|
}
|
|
|
- int attrAlpha = 0;
|
|
|
- String attrContent = "";
|
|
|
- if (!cpdfAnnotation.isValid()) {
|
|
|
- return annotListItems;
|
|
|
- }
|
|
|
- switch (cpdfAnnotation.getType()){
|
|
|
- case TEXT:
|
|
|
- CPDFTextAnnotation textAnnotation = (CPDFTextAnnotation) cpdfAnnotation;
|
|
|
- attrColor = textAnnotation.getColor();
|
|
|
- attrAlpha = textAnnotation.getAlpha();
|
|
|
- attrContent = textAnnotation.getContent();
|
|
|
- break;
|
|
|
- case HIGHLIGHT:
|
|
|
- CPDFHighlightAnnotation highlightAnnotation = (CPDFHighlightAnnotation) cpdfAnnotation;
|
|
|
- attrColor = highlightAnnotation.getColor();
|
|
|
- attrAlpha = highlightAnnotation.getAlpha();
|
|
|
- attrContent = highlightAnnotation.getMarkedText();
|
|
|
- break;
|
|
|
- case UNDERLINE:
|
|
|
- CPDFUnderlineAnnotation underlineAnnotation = (CPDFUnderlineAnnotation) cpdfAnnotation;
|
|
|
- attrColor = underlineAnnotation.getColor();
|
|
|
- attrAlpha = underlineAnnotation.getAlpha();
|
|
|
- attrContent = underlineAnnotation.getMarkedText();
|
|
|
- break;
|
|
|
- case STRIKEOUT:
|
|
|
- CPDFStrikeoutAnnotation strikeoutAnnotation = (CPDFStrikeoutAnnotation) cpdfAnnotation;
|
|
|
- attrColor = strikeoutAnnotation.getColor();
|
|
|
- attrAlpha = strikeoutAnnotation.getAlpha();
|
|
|
- attrContent = strikeoutAnnotation.getMarkedText();
|
|
|
- break;
|
|
|
- case SQUIGGLY:
|
|
|
- CPDFSquigglyAnnotation squigglyAnnotation = (CPDFSquigglyAnnotation) cpdfAnnotation;
|
|
|
- attrColor = squigglyAnnotation.getColor();
|
|
|
- attrAlpha = squigglyAnnotation.getAlpha();
|
|
|
- attrContent = squigglyAnnotation.getMarkedText();
|
|
|
- break;
|
|
|
- case INK:
|
|
|
- CPDFInkAnnotation cpdfInkAnnotation = (CPDFInkAnnotation) cpdfAnnotation;
|
|
|
- attrColor = cpdfInkAnnotation.getColor();
|
|
|
- attrAlpha = cpdfInkAnnotation.getAlpha();
|
|
|
- attrContent = cpdfInkAnnotation.getContent();
|
|
|
- break;
|
|
|
- case LINE:
|
|
|
- CPDFLineAnnotation lineAnnotation = (CPDFLineAnnotation) cpdfAnnotation;
|
|
|
- isArrowLine = lineAnnotation.getLineHeadType() == CPDFLineAnnotation.LineType.LINETYPE_ARROW;
|
|
|
- attrColor = lineAnnotation.getBorderColor();
|
|
|
- attrAlpha = lineAnnotation.getBorderAlpha();
|
|
|
- attrContent = lineAnnotation.getContent();
|
|
|
- break;
|
|
|
- case FREETEXT:
|
|
|
- CPDFFreetextAnnotation annotation = (CPDFFreetextAnnotation) cpdfAnnotation;
|
|
|
- attrContent = annotation.getContent();
|
|
|
- break;
|
|
|
- case STAMP:
|
|
|
- CPDFStampAnnotation stampAnnotation = (CPDFStampAnnotation) cpdfAnnotation;
|
|
|
- attrContent = stampAnnotation.getContent();
|
|
|
- if (stampAnnotation.isStampSignature()){
|
|
|
- continue;
|
|
|
- }
|
|
|
- break;
|
|
|
- case SQUARE:
|
|
|
- CPDFSquareAnnotation squareAnnotation = (CPDFSquareAnnotation) cpdfAnnotation;
|
|
|
- attrColor = squareAnnotation.getBorderColor();
|
|
|
- attrAlpha = squareAnnotation.getBorderAlpha();
|
|
|
- attrContent = squareAnnotation.getContent();
|
|
|
- break;
|
|
|
- case CIRCLE:
|
|
|
- CPDFCircleAnnotation circleAnnotation = (CPDFCircleAnnotation) cpdfAnnotation;
|
|
|
- attrColor = circleAnnotation.getBorderColor();
|
|
|
- attrAlpha = circleAnnotation.getBorderAlpha();
|
|
|
- attrContent = circleAnnotation.getContent();
|
|
|
- break;
|
|
|
- case SOUND:
|
|
|
- CPDFSoundAnnotation soundAnnotation = (CPDFSoundAnnotation) cpdfAnnotation;
|
|
|
- attrContent = soundAnnotation.getContent();
|
|
|
- break;
|
|
|
- default:
|
|
|
- continue;
|
|
|
- }
|
|
|
- CPDFAnnotListItem item = new CPDFAnnotListItem();
|
|
|
- item.setAnnotType(type);
|
|
|
- item.setArrowLine(isArrowLine);
|
|
|
- item.setModifyDate(CDateUtil.transformPDFDate(attrTime));
|
|
|
- item.setColor(attrColor);
|
|
|
- item.setColorAlpha(attrAlpha);
|
|
|
- item.setContent(attrContent);
|
|
|
- item.setPage(page);
|
|
|
- item.setAnnotationCount(0);
|
|
|
- item.setAttr(cpdfAnnotation);
|
|
|
- item.setHeader(false);
|
|
|
- annotListItems.add(item);
|
|
|
}
|
|
|
return annotListItems;
|
|
|
}
|
|
|
|
|
|
+ public static CPDFAnnotListItem convertToListItem(CPDFAnnotation cpdfAnnotation){
|
|
|
+ CPDFAnnotation.Type type = cpdfAnnotation.getType();
|
|
|
+ boolean isArrowLine = true;
|
|
|
+ int attrColor = Color.TRANSPARENT;
|
|
|
+ String attrTime = "";
|
|
|
+ CPDFDate modifyDate = cpdfAnnotation.getRecentlyModifyDate();
|
|
|
+ if (null != modifyDate){
|
|
|
+ attrTime = CPDFDate.toStandardDate(modifyDate);
|
|
|
+ }
|
|
|
+ int attrAlpha = 0;
|
|
|
+ String attrContent = "";
|
|
|
+ switch (cpdfAnnotation.getType()){
|
|
|
+ case TEXT:
|
|
|
+ CPDFTextAnnotation textAnnotation = (CPDFTextAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = textAnnotation.getColor();
|
|
|
+ attrAlpha = textAnnotation.getAlpha();
|
|
|
+ attrContent = textAnnotation.getContent();
|
|
|
+ break;
|
|
|
+ case HIGHLIGHT:
|
|
|
+ CPDFHighlightAnnotation highlightAnnotation = (CPDFHighlightAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = highlightAnnotation.getColor();
|
|
|
+ attrAlpha = highlightAnnotation.getAlpha();
|
|
|
+ attrContent = highlightAnnotation.getMarkedText();
|
|
|
+ break;
|
|
|
+ case UNDERLINE:
|
|
|
+ CPDFUnderlineAnnotation underlineAnnotation = (CPDFUnderlineAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = underlineAnnotation.getColor();
|
|
|
+ attrAlpha = underlineAnnotation.getAlpha();
|
|
|
+ attrContent = underlineAnnotation.getMarkedText();
|
|
|
+ break;
|
|
|
+ case STRIKEOUT:
|
|
|
+ CPDFStrikeoutAnnotation strikeoutAnnotation = (CPDFStrikeoutAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = strikeoutAnnotation.getColor();
|
|
|
+ attrAlpha = strikeoutAnnotation.getAlpha();
|
|
|
+ attrContent = strikeoutAnnotation.getMarkedText();
|
|
|
+ break;
|
|
|
+ case SQUIGGLY:
|
|
|
+ CPDFSquigglyAnnotation squigglyAnnotation = (CPDFSquigglyAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = squigglyAnnotation.getColor();
|
|
|
+ attrAlpha = squigglyAnnotation.getAlpha();
|
|
|
+ attrContent = squigglyAnnotation.getMarkedText();
|
|
|
+ break;
|
|
|
+ case INK:
|
|
|
+ CPDFInkAnnotation cpdfInkAnnotation = (CPDFInkAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = cpdfInkAnnotation.getColor();
|
|
|
+ attrAlpha = cpdfInkAnnotation.getAlpha();
|
|
|
+ attrContent = cpdfInkAnnotation.getContent();
|
|
|
+ break;
|
|
|
+ case LINE:
|
|
|
+ CPDFLineAnnotation lineAnnotation = (CPDFLineAnnotation) cpdfAnnotation;
|
|
|
+ isArrowLine = lineAnnotation.getLineHeadType() == CPDFLineAnnotation.LineType.LINETYPE_ARROW;
|
|
|
+ attrColor = lineAnnotation.getBorderColor();
|
|
|
+ attrAlpha = lineAnnotation.getBorderAlpha();
|
|
|
+ attrContent = lineAnnotation.getContent();
|
|
|
+ break;
|
|
|
+ case FREETEXT:
|
|
|
+ CPDFFreetextAnnotation annotation = (CPDFFreetextAnnotation) cpdfAnnotation;
|
|
|
+ attrContent = annotation.getContent();
|
|
|
+ break;
|
|
|
+ case STAMP:
|
|
|
+ CPDFStampAnnotation stampAnnotation = (CPDFStampAnnotation) cpdfAnnotation;
|
|
|
+ attrContent = stampAnnotation.getContent();
|
|
|
+ if (stampAnnotation.isStampSignature()){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SQUARE:
|
|
|
+ CPDFSquareAnnotation squareAnnotation = (CPDFSquareAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = squareAnnotation.getBorderColor();
|
|
|
+ attrAlpha = squareAnnotation.getBorderAlpha();
|
|
|
+ attrContent = squareAnnotation.getContent();
|
|
|
+ break;
|
|
|
+ case CIRCLE:
|
|
|
+ CPDFCircleAnnotation circleAnnotation = (CPDFCircleAnnotation) cpdfAnnotation;
|
|
|
+ attrColor = circleAnnotation.getBorderColor();
|
|
|
+ attrAlpha = circleAnnotation.getBorderAlpha();
|
|
|
+ attrContent = circleAnnotation.getContent();
|
|
|
+ break;
|
|
|
+ case SOUND:
|
|
|
+ CPDFSoundAnnotation soundAnnotation = (CPDFSoundAnnotation) cpdfAnnotation;
|
|
|
+ attrContent = soundAnnotation.getContent();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ CPDFAnnotListItem item = new CPDFAnnotListItem();
|
|
|
+ item.setAnnotType(type);
|
|
|
+ item.setArrowLine(isArrowLine);
|
|
|
+ item.setModifyDate(CDateUtil.transformPDFDate(attrTime));
|
|
|
+ item.setColor(attrColor);
|
|
|
+ item.setColorAlpha(attrAlpha);
|
|
|
+ item.setContent(attrContent);
|
|
|
+ item.setPage(cpdfAnnotation.pdfPage.getPageNum());
|
|
|
+ item.setAnnotationCount(0);
|
|
|
+ item.setAttr(cpdfAnnotation);
|
|
|
+ item.setHeader(false);
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* export annotations to xfdf file
|