{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "pdf-viewer-semantic-text-comparison",
  "framework": "vue",
  "type": "registry:component",
  "component": "PdfViewer",
  "variant": "semantic-text-comparison",
  "dependencies": [
    "@syncfusion/ej2-vue-pdfviewer"
  ],
  "description": "PDF viewer sample comparing two uploaded documents with synchronized navigation and highlighted text differences.",
  "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-semantic-text-comparison.md"
  },
  "files": [
    {
      "target": "src/components/pdf-viewer-semantic-text-comparison/PdfViewer.vue",
      "content": "<template>\n  <div class=\"control-section semantic-comparison\">\n    <div class=\"uploaders\">\n      <label>Original PDF <input ref=\"originalInput\" type=\"file\" accept=\".pdf\" @change=\"selectFile($event, true)\" /></label>\n      <span>{{ originalName }}</span>\n      <label>Modified PDF <input ref=\"modifiedInput\" type=\"file\" accept=\".pdf\" @change=\"selectFile($event, false)\" /></label>\n      <span>{{ modifiedName }}</span>\n      <button class=\"e-btn e-primary\" type=\"button\" :disabled=\"!originalFile || !modifiedFile\" @click=\"compare\">Compare</button>\n      <button v-if=\"originalFile\" class=\"e-btn\" type=\"button\" @click=\"clearFile(true)\">Remove original</button>\n      <button v-if=\"modifiedFile\" class=\"e-btn\" type=\"button\" @click=\"clearFile(false)\">Remove modified</button>\n    </div>\n    <div id=\"comparer-container\" ref=\"comparerContainer\"></div>\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport { PdfComparer } from '@syncfusion/ej2-pdfviewer';\nimport { markRaw } from 'vue';\n\nexport default {\n  data() {\n    return {\n      originalFile: null as File | null, modifiedFile: null as File | null,\n      originalPath: 'https://cdn.syncfusion.com/content/pdf/original-document.pdf',\n      modifiedPath: 'https://cdn.syncfusion.com/content/pdf/modified-document.pdf',\n      originalName: 'Choose a PDF file', modifiedName: 'Choose a PDF file',\n      comparer: null as PdfComparer | null\n    };\n  },\n  methods: {\n    selectFile(event: Event, original: boolean) {\n      const file = (event.target as HTMLInputElement).files?.[0];\n      if (!file) return;\n      if (!file.name.toLowerCase().endsWith('.pdf')) { alert('Please select a valid PDF file.'); return; }\n      if (original) {\n        this.releasePath(true); this.originalFile = file; this.originalPath = URL.createObjectURL(file); this.originalName = file.name;\n      } else {\n        this.releasePath(false); this.modifiedFile = file; this.modifiedPath = URL.createObjectURL(file); this.modifiedName = file.name;\n      }\n    },\n    releasePath(original: boolean) {\n      const path = original ? this.originalPath : this.modifiedPath;\n      if (!path.startsWith('https://')) URL.revokeObjectURL(path);\n    },\n    clearFile(original: boolean) {\n      if (original) { this.releasePath(true); this.originalFile = null; this.originalPath = 'https://cdn.syncfusion.com/content/pdf/original-document.pdf'; this.originalName = 'Choose a PDF file'; (this.$refs.originalInput as HTMLInputElement).value = ''; }\n      else { this.releasePath(false); this.modifiedFile = null; this.modifiedPath = 'https://cdn.syncfusion.com/content/pdf/modified-document.pdf'; this.modifiedName = 'Choose a PDF file'; (this.$refs.modifiedInput as HTMLInputElement).value = ''; }\n    },\n    compare() {\n      if (!this.originalFile || !this.modifiedFile) return;\n      this.comparer?.destroy();\n      this.comparer = markRaw(new PdfComparer({\n        originalDocumentPath: this.originalPath, modifiedDocumentPath: this.modifiedPath,\n        resourceUrl: 'https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib',\n        comparisonOptions: { beforeColor: '#FF0000', afterColor: '#00FF00', beforeColorOpacity: 0.4, afterColorOpacity: 0.4, enableHighlights: true } as any,\n        enableDifferencePanel: true, enableSyncScrolling: true\n      }));\n      this.comparer.appendTo(this.$refs.comparerContainer as HTMLElement);\n      this.comparer.compare();\n    }\n  },\n  beforeUnmount() {\n    this.releasePath(true); this.releasePath(false); this.comparer?.destroy();\n  }\n};\n</script>\n\n<style scoped>\n.uploaders { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 0 16px; }\n.uploaders label { font-weight: 600; }\n.uploaders span { color: #666; font-size: 12px; margin-right: 8px; }\n#comparer-container { height: 640px; width: 100%; }\n</style>\n"
    }
  ]
}