إضافة تعليق توضيحي لمرفق الملف

Contents
[ ]

تسمح لك التعليقات التوضيحية لمرفقات الملفات بتضمين ملفات خارجية كرموز تفاعلية على صفحة PDF. باستخدام التحميل الزائد لمسار الملف، يمكنك إرفاق الملفات مباشرة من القرص دون فتح التدفقات يدويًا. تتيح لك هذه الطريقة أيضًا تخصيص رمز التعليق التوضيحي وتقديم وصف للمستخدمين.

  1. قم بإنشاء محرر محتوى PDF كائن.
  2. قم بربط ملف PDF المدخل.
  3. حدد مستطيل التعليق التوضيحي.
  4. أضف التعليق التوضيحي لمرفق الملف.
  5. احفظ المستند المحدث.
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
from io import BytesIO
import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def add_file_attachment_annotation(infile, attachment_file, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Create file attachment annotation on page 1
    content_editor.create_file_attachment(
        apd.Rectangle(100, 520, 20, 20),
        "Attachment annotation contents",
        attachment_file,
        1,
        "PushPin",
    )
    # Save updated document
    content_editor.save(outfile)