التعليقات

هذه الدليل تظهر كيفية إضافة وتهيئة وإزالة التعليقات من PDF باستخدام Annotation تسلسل التسلسل الهرمي للصفوف في Aspose.PDF FOSS لـ Java . سوف تتعلم أن خلق المنتجات، النص الحر، تسليط الضوء، والدوار التعليقات، وتسوية أو حذفهم باستخدام PdfAnnotationEditor.

تسلسل التسجيلات

التجريدي Annotation class هو أساس جميع التعليقات PDF. كل التعليمات يتم وضعها على Page في a Rectangle ويتم إضافتها عبر: page.getAnnotations().add(annotation).

WidgetAnnotation

WidgetAnnotation يمثل أداة نموذج. يتم التحكم في المظهر من خلال AppearanceCharacteristics,، والتي تكشف setBorder(), setBackground(), setRotate(),، و setCaption().

try (Document doc = new Document()) {
    PageCollection pages = doc.getPages();
    Page page = pages.add();
    WidgetAnnotation w = new WidgetAnnotation(page, new Rectangle(0, 0, 100, 50));
    w.getCharacteristics().setBorder(Color.fromRgb(1, 0, 0));
    w.getCharacteristics().setCaption("Submit");
    page.getAnnotations().add(w);
    doc.save("annotated.pdf");
}

FreeTextAnnotation

FreeTextAnnotation يعرض استدعاء نصي في موقع محدد. إنه يقبل a DefaultAppearance لتعيين الخط والحجم واللون من نص التعليقات.

DefaultAppearance da = new DefaultAppearance("Helv", 12, Color.BLACK);
FreeTextAnnotation fta = new FreeTextAnnotation(page,
    new Rectangle(50, 50, 200, 100), da);
fta.setContents("Review comment here");
page.getAnnotations().add(fta);

setCallout(double[][]) يضع خط التنظيم من ثلاث نقاط للتعليقات. getIntent() يعيد التعليقات FreeTextIntent قيمة.

ملاحظات التسمية

HighlightAnnotation و UnderlineAnnotation علامة النص الممتدة مع نقاط رباعية. المجلس الوزاري getQuadPoints() طريقة يعود 8 عناصر المصفوفة التي تحدد الزوايا الأربعة من المنطقة المميزة.

try (Document doc = new Document("input.pdf")) {
    PageCollection pages = doc.getPages();
    Page page = pages.get(1);
    HighlightAnnotation h = new HighlightAnnotation(page,
        new Rectangle(100, 200, 300, 220));
    page.getAnnotations().add(h);
    doc.save("highlighted.pdf");
}

إشارة الدائرة وإشارات الرعاية

CircleAnnotation رسم إصطحاف على المستطيل المعين.; CaretAnnotation علامات نقطة إدراج في النص. كلاهما يمتد إلى Annotation ويشاركون نفس اللون و العقارات الحدودية.

try (Document doc = new Document()) {
    PageCollection pages = doc.getPages();
    Page page = pages.add();
    CircleAnnotation circle = new CircleAnnotation(page, new Rectangle(100, 100, 200, 200));
    circle.setColor(Color.fromRgb(0, 0, 1));
    page.getAnnotations().add(circle);
    doc.save("circle.pdf");
}

التعليقات المصفحة

استخدام PdfAnnotationEditor.flattenAnnotations() لدمج جميع التعليقات في الملف يُعدّ ذلك من عدم إمكانية تحريرها.

try (PdfAnnotationEditor editor = new PdfAnnotationEditor()) {
    editor.bindPdf("annotated.pdf");
    editor.flattenAnnotations();
    editor.save("flat.pdf");
}

إزالة التعليقات حسب النوع

اتصلوا deleteAnnotations(type) مع اسم نوع التعليقات لإزالة جميع التعليفات من هذا النوع من كل صفحة في المستند المقفل:

try (PdfAnnotationEditor editor = new PdfAnnotationEditor()) {
    editor.bindPdf("input.pdf");
    editor.deleteAnnotations("Highlight");
    editor.save("output.pdf");
}

انظر أيضا

 العربية