{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "pdf-viewer-programmatic-annotations",
  "framework": "vue",
  "type": "registry:component",
  "component": "PdfViewer",
  "variant": "programmatic-annotations",
  "dependencies": [
    "@syncfusion/ej2-vue-pdfviewer",
    "@syncfusion/ej2-vue-dropdowns"
  ],
  "description": "PDF viewer sample selecting annotation types from a dropdown and adding them programmatically to the document.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/vue/llms.txt",
    "skillPack": "syncfusion/vue-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/vue/pdf-viewer-programmatic-annotations.md"
  },
  "files": [
    {
      "target": "src/components/pdf-viewer-programmatic-annotations/PdfViewer.vue",
      "content": "<template>\n  <div class=\"control-section programmatic-annotations\">\n    <div class=\"controls\">\n      <label for=\"annotation-type\">Annotation type</label>\n      <DropDownListComponent\n        id=\"annotation-type\"\n        ref=\"annotationType\"\n        :dataSource=\"annotationTypes\"\n        :fields=\"{ text: 'text', value: 'value' }\"\n        value=\"Highlight\"\n        width=\"220px\"\n      />\n      <button class=\"e-btn e-primary\" type=\"button\" :disabled=\"!isDocumentLoaded\" @click=\"addAnnotation\">\n        Add annotation\n      </button>\n    </div>\n    <p role=\"status\">{{ statusMessage }}</p>\n    <PdfViewerComponent\n      id=\"pdfViewer\"\n      ref=\"pdfviewer\"\n      :documentPath=\"documentPath\"\n      :resourceUrl=\"resourceUrl\"\n      :documentLoad=\"documentLoad\"\n    />\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { provide, ref } from 'vue';\nimport { DropDownListComponent } from '@syncfusion/ej2-vue-dropdowns';\nimport {\n  Annotation, BookmarkView, FormDesigner, FormFields, LinkAnnotation, Magnification,\n  Navigation, PageOrganizer, PdfViewerComponent, Print, TextSearch, TextSelection,\n  ThumbnailView, Toolbar\n} from '@syncfusion/ej2-vue-pdfviewer';\n\nprovide('PdfViewer', [\n  Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView,\n  Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer\n]);\n\nconst pdfviewer = ref<InstanceType<typeof PdfViewerComponent> | null>(null);\nconst annotationType = ref<InstanceType<typeof DropDownListComponent> | null>(null);\nconst isDocumentLoaded = ref(false);\nconst statusMessage = ref('Loading PDF document...');\nconst annotationCount = ref(0);\nconst documentPath = 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';\nconst resourceUrl = 'https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib';\nconst annotationTypes = [\n  'Highlight', 'Underline', 'Strikethrough', 'Squiggly', 'Line', 'Arrow',\n  'Rectangle', 'Circle', 'Polygon', 'Distance', 'Perimeter', 'Area', 'Radius',\n  'Volume', 'StickyNotes', 'Ink', 'Stamp', 'FreeText'\n].map((value) => ({ text: value, value }));\n\nconst documentLoad = (): void => {\n  isDocumentLoaded.value = true;\n  statusMessage.value = 'Document loaded. Choose an annotation type and add it to the current page.';\n};\n\nconst addAnnotation = (): void => {\n  const viewer = pdfviewer.value?.ej2Instances;\n  const type = annotationType.value?.ej2Instances.value as string | undefined;\n  if (!viewer || !type) {\n    return;\n  }\n\n  const index = annotationCount.value++ % 16;\n  const offset = { x: 100 + (index % 4) * 115, y: 120 + Math.floor(index / 4) * 75 };\n  const end = { x: offset.x + 120, y: offset.y + 45 };\n  const base = { offset, pageNumber: viewer.currentPageNumber, author: 'Guest', opacity: 1 };\n  let settings: Record<string, unknown> = base;\n\n  if (['Highlight', 'Underline', 'Strikethrough', 'Squiggly'].includes(type)) {\n    settings = { ...base, bounds: [{ x: offset.x, y: offset.y, width: 180, height: 16 }], color: type === 'Highlight' ? '#FFDF56' : '#FF0000' };\n  } else if (['Line', 'Arrow', 'Distance'].includes(type)) {\n    settings = { ...base, vertexPoints: [offset, end], lineHeadEndStyle: type === 'Arrow' ? 'Closed' : 'None' };\n  } else if (type === 'Rectangle') {\n    settings = { ...base, width: 100, height: 70, strokeColor: '#2563eb' };\n  } else if (['Circle', 'Radius'].includes(type)) {\n    settings = { ...base, width: 80, height: 80, strokeColor: '#2563eb' };\n  } else if (type === 'FreeText') {\n    settings = { ...base, width: 190, height: 32, fontSize: 14, fontColor: '#1f2937', defaultText: 'Added programmatically' };\n  } else {\n    settings = { ...base, width: 100, height: 60 };\n  }\n\n  viewer.annotation.addAnnotation(type as never, settings as never);\n  statusMessage.value = `${type} annotation added to page ${viewer.currentPageNumber}.`;\n};\n</script>\n\n<style scoped>\n.controls { display: flex; align-items: end; gap: 12px; padding: 8px 0 12px; }\n.controls label { font-weight: 600; }\n#pdfViewer { height: 640px; }\n</style>\n"
    }
  ]
}