|
@@ -1,8 +1,14 @@
|
|
package com.compdfkit.samples.samples;
|
|
package com.compdfkit.samples.samples;
|
|
|
|
|
|
|
|
+import android.graphics.Color;
|
|
|
|
+import android.graphics.RectF;
|
|
|
|
+
|
|
import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFAnnotation;
|
|
|
|
+import com.compdfkit.core.annotation.CPDFFreetextAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFReplyAnnotation;
|
|
import com.compdfkit.core.annotation.CPDFReplyAnnotation;
|
|
|
|
+import com.compdfkit.core.annotation.CPDFTextAttribute;
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
import com.compdfkit.core.document.CPDFDocument;
|
|
|
|
+import com.compdfkit.core.page.CPDFPage;
|
|
import com.compdfkit.samples.PDFSamples;
|
|
import com.compdfkit.samples.PDFSamples;
|
|
import com.compdfkit.samples.R;
|
|
import com.compdfkit.samples.R;
|
|
import com.compdfkit.samples.util.FileUtils;
|
|
import com.compdfkit.samples.util.FileUtils;
|
|
@@ -22,18 +28,31 @@ public class AnnotationReplyTest extends PDFSamples {
|
|
super.run(outputListener);
|
|
super.run(outputListener);
|
|
printHead();
|
|
printHead();
|
|
printDividingLine();
|
|
printDividingLine();
|
|
- CPDFDocument document = new CPDFDocument(context);
|
|
|
|
- document.open(FileUtils.getAssetsTempFile(context, "Annotations.pdf"));
|
|
|
|
|
|
+ CPDFDocument document = CPDFDocument.createDocument(context);
|
|
|
|
+ document.insertBlankPage(0, 595, 842);
|
|
|
|
|
|
|
|
+ // Insert the free text annotation into the first page of the PDF document.
|
|
|
|
+ CPDFPage page = document.pageAtIndex(0);
|
|
|
|
+ CPDFFreetextAnnotation freetextAnnotation = (CPDFFreetextAnnotation) page.addAnnot(CPDFAnnotation.Type.FREETEXT);
|
|
|
|
+ RectF size = page.getSize();
|
|
|
|
+ RectF freeText1Rect = page.convertRectToPage(false, size.width(), size.height(), new RectF(10, 20, 160, 100));
|
|
|
|
+ freetextAnnotation.setRect(freeText1Rect);
|
|
|
|
+ freetextAnnotation.setContent("FreeText Annotation Reply Test");
|
|
|
|
+ CPDFTextAttribute textAttribute = new CPDFTextAttribute(CPDFTextAttribute.FontNameHelper.obtainFontName(
|
|
|
|
+ CPDFTextAttribute.FontNameHelper.FontType.Courier, false, false
|
|
|
|
+ ), 12, Color.RED);
|
|
|
|
+ freetextAnnotation.setFreetextDa(textAttribute);
|
|
|
|
+ // set text color opacity
|
|
|
|
+ freetextAnnotation.setAlpha(255);
|
|
|
|
+ freetextAnnotation.setTitle("ComPDFKit");
|
|
|
|
+ freetextAnnotation.updateAp();
|
|
|
|
|
|
// ----------------------------------------
|
|
// ----------------------------------------
|
|
// Samples1 : create annotation reply info
|
|
// Samples1 : create annotation reply info
|
|
- // Get the first annotation on the first page
|
|
|
|
- CPDFAnnotation annotation = document.pageAtIndex(0).getAnnotations().get(0);
|
|
|
|
- annotation.setTitle("Guest");
|
|
|
|
- if (annotation.getAllReplyAnnotations() == null || annotation.getAllReplyAnnotations().length == 0) {
|
|
|
|
- outputListener.println("Annotation Type:" + annotation.getType().name());
|
|
|
|
- CPDFReplyAnnotation replyAnnotation = annotation.createReplyAnnotation();
|
|
|
|
|
|
+ if (freetextAnnotation.getAllReplyAnnotations() == null || freetextAnnotation.getAllReplyAnnotations().length == 0) {
|
|
|
|
+ outputListener.println("Annotation Type:" + freetextAnnotation.getType().name());
|
|
|
|
+ // -----------------------
|
|
|
|
+ CPDFReplyAnnotation replyAnnotation = freetextAnnotation.createReplyAnnotation();
|
|
replyAnnotation.setMarkedAnnotState(CPDFAnnotation.MarkState.MARKED);
|
|
replyAnnotation.setMarkedAnnotState(CPDFAnnotation.MarkState.MARKED);
|
|
replyAnnotation.setReviewAnnotState(CPDFAnnotation.ReviewState.REVIEW_COMPLETED);
|
|
replyAnnotation.setReviewAnnotState(CPDFAnnotation.ReviewState.REVIEW_COMPLETED);
|
|
replyAnnotation.setTitle("Youna");
|
|
replyAnnotation.setTitle("Youna");
|
|
@@ -46,7 +65,8 @@ public class AnnotationReplyTest extends PDFSamples {
|
|
outputListener.println("Create Reply Annotation End !!!");
|
|
outputListener.println("Create Reply Annotation End !!!");
|
|
printDividingLine();
|
|
printDividingLine();
|
|
|
|
|
|
- CPDFReplyAnnotation replyAnnotation1 = annotation.createReplyAnnotation();
|
|
|
|
|
|
+ // -----------------------
|
|
|
|
+ CPDFReplyAnnotation replyAnnotation1 = freetextAnnotation.createReplyAnnotation();
|
|
replyAnnotation1.setMarkedAnnotState(CPDFAnnotation.MarkState.UNMARKED);
|
|
replyAnnotation1.setMarkedAnnotState(CPDFAnnotation.MarkState.UNMARKED);
|
|
replyAnnotation1.setReviewAnnotState(CPDFAnnotation.ReviewState.REVIEW_ACCEPTED);
|
|
replyAnnotation1.setReviewAnnotState(CPDFAnnotation.ReviewState.REVIEW_ACCEPTED);
|
|
replyAnnotation1.setTitle("C-Long");
|
|
replyAnnotation1.setTitle("C-Long");
|
|
@@ -58,14 +78,13 @@ public class AnnotationReplyTest extends PDFSamples {
|
|
outputListener.println("MarkedState:" + replyAnnotation1.getMarkedAnnotState().name());
|
|
outputListener.println("MarkedState:" + replyAnnotation1.getMarkedAnnotState().name());
|
|
outputListener.println("Create Reply Annotation End !!!");
|
|
outputListener.println("Create Reply Annotation End !!!");
|
|
printDividingLine();
|
|
printDividingLine();
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// Samples 2: get all reply annotations
|
|
// Samples 2: get all reply annotations
|
|
- CPDFReplyAnnotation[] replyAnnotations = annotation.getAllReplyAnnotations();
|
|
|
|
|
|
+ CPDFReplyAnnotation[] replyAnnotations = freetextAnnotation.getAllReplyAnnotations();
|
|
outputListener.println("Get All Reply Annotations: ");
|
|
outputListener.println("Get All Reply Annotations: ");
|
|
outputListener.println("Size: " + replyAnnotations.length);
|
|
outputListener.println("Size: " + replyAnnotations.length);
|
|
- outputListener.println("Annotation Type:" + annotation.getType().name());
|
|
|
|
|
|
+ outputListener.println("Annotation Type:" + freetextAnnotation.getType().name());
|
|
if (replyAnnotations != null) {
|
|
if (replyAnnotations != null) {
|
|
for (CPDFReplyAnnotation replyAnnotation : replyAnnotations) {
|
|
for (CPDFReplyAnnotation replyAnnotation : replyAnnotations) {
|
|
printDividingLine();
|
|
printDividingLine();
|