{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "pdf-viewer-semantic-text-comparison",
  "framework": "angular",
  "type": "registry:component",
  "component": "PdfViewer",
  "variant": "semantic-text-comparison",
  "dependencies": [
    "@syncfusion/ej2-pdfviewer"
  ],
  "description": "Compare two PDFs with synchronized scrolling, highlighted text changes, and a difference panel.",
  "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/angular/llms.txt",
    "skillPack": "syncfusion/angular-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/angular/pdf-viewer-semantic-text-comparison.md"
  },
  "files": [
    {
      "target": "src/components/pdf-viewer-semantic-text-comparison/pdf-viewer.component.html",
      "content": "<div class=\"control-section\">\n    <div role=\"group\" aria-label=\"PDF comparison files\"\n        style=\"display:flex;align-items:flex-end;flex-wrap:wrap;gap:12px;margin-bottom:12px\">\n        <div style=\"min-width:260px;flex:1 1 260px\">\n            <label for=\"original-pdf-file\" style=\"display:block;margin-bottom:4px\">Original document</label>\n            <input id=\"original-pdf-file\" class=\"e-input\" type=\"file\" accept=\".pdf,application/pdf\"\n                (change)=\"onOriginalFileChange($event)\">\n            <div style=\"margin-top:4px\">{{ originalFile?.name ?? 'Choose a PDF file' }}</div>\n        </div>\n        <div style=\"min-width:260px;flex:1 1 260px\">\n            <label for=\"modified-pdf-file\" style=\"display:block;margin-bottom:4px\">Modified document</label>\n            <input id=\"modified-pdf-file\" class=\"e-input\" type=\"file\" accept=\".pdf,application/pdf\"\n                (change)=\"onModifiedFileChange($event)\">\n            <div style=\"margin-top:4px\">{{ modifiedFile?.name ?? 'Choose a PDF file' }}</div>\n        </div>\n        <button class=\"e-btn e-primary\" type=\"button\" (click)=\"compareDocuments()\"\n            [disabled]=\"!originalFile || !modifiedFile || isComparing\">\n            {{ isComparing ? 'Comparing...' : 'Compare' }}\n        </button>\n    </div>\n    <p role=\"status\" aria-live=\"polite\">{{ statusMessage }}</p>\n    <div #comparerContainer [hidden]=\"!comparisonVisible\" style=\"height:640px;width:100%\"></div>\n</div>\n"
    },
    {
      "target": "src/components/pdf-viewer-semantic-text-comparison/pdf-viewer.component.ts",
      "content": "import { ChangeDetectorRef, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';\nimport { PdfComparer, TextComparisonOptions } from '@syncfusion/ej2-pdfviewer';\n\ninterface ComparisonDocuments {\n    original: string;\n    modified: string;\n}\n\n@Component({\n    selector: 'control-content',\n    templateUrl: 'pdf-viewer.component.html',\n    standalone: true\n})\nexport class SemanticTextComparisonComponent implements OnDestroy {\n    @ViewChild('comparerContainer', { static: true })\n    private comparerContainer!: ElementRef<HTMLDivElement>;\n\n    public readonly resource = 'https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib';\n    public originalFile: File | null = null;\n    public modifiedFile: File | null = null;\n    public comparisonVisible = false;\n    public isComparing = false;\n    public statusMessage = 'Choose two PDF files to compare.';\n    private comparer: PdfComparer | null = null;\n    private comparisonDocuments: ComparisonDocuments | null = null;\n\n    private readonly comparisonOptions = {\n        beforeColor: '#FF0000',\n        afterColor: '#00FF00',\n        beforeColorOpacity: 0.4,\n        afterColorOpacity: 0.4,\n        enableHighlights: true\n    } as TextComparisonOptions;\n\n    constructor(private readonly changeDetector: ChangeDetectorRef) {}\n\n    public onOriginalFileChange(event: Event): void {\n        this.resetComparison();\n        this.originalFile = this.getPdfFile(event, 'Original');\n        if (this.originalFile) {\n            this.statusMessage = 'PDF selected. Choose the other document or compare the selected files.';\n        }\n    }\n\n    public onModifiedFileChange(event: Event): void {\n        this.resetComparison();\n        this.modifiedFile = this.getPdfFile(event, 'Modified');\n        if (this.modifiedFile) {\n            this.statusMessage = 'PDF selected. Choose the other document or compare the selected files.';\n        }\n    }\n\n    public async compareDocuments(): Promise<void> {\n        if (!this.originalFile || !this.modifiedFile) {\n            return;\n        }\n\n        this.resetComparison();\n        this.isComparing = true;\n        this.statusMessage = 'Loading PDF documents for comparison...';\n        try {\n            this.comparisonDocuments = {\n                original: URL.createObjectURL(this.originalFile),\n                modified: URL.createObjectURL(this.modifiedFile)\n            };\n            this.comparisonVisible = true;\n            this.changeDetector.detectChanges();\n\n            this.comparer = new PdfComparer({\n                originalDocumentPath: this.comparisonDocuments.original,\n                modifiedDocumentPath: this.comparisonDocuments.modified,\n                resourceUrl: this.resource,\n                comparisonOptions: this.comparisonOptions,\n                enableDifferencePanel: true,\n                enableSyncScrolling: true,\n                height: '640px',\n                width: '100%'\n            });\n            this.comparer.appendTo(this.comparerContainer.nativeElement);\n            await this.comparer.compare();\n            this.statusMessage = 'Comparison requested. Review the highlighted changes in both viewers and the difference panel.';\n        } catch (error) {\n            console.error('Unable to compare the selected PDF documents.', error);\n            this.statusMessage = 'Unable to compare the selected PDFs. See the browser console for details.';\n            this.disposeComparer();\n        } finally {\n            this.isComparing = false;\n        }\n    }\n\n    public ngOnDestroy(): void {\n        this.disposeComparer();\n    }\n\n    private getPdfFile(event: Event, label: string): File | null {\n        const input = event.currentTarget as HTMLInputElement;\n        const file = input.files?.[0] ?? null;\n        if (file && !file.name.toLowerCase().endsWith('.pdf')) {\n            this.statusMessage = `${label} file must have a .pdf extension.`;\n            input.value = '';\n            return null;\n        }\n        return file;\n    }\n\n    private resetComparison(): void {\n        this.disposeComparer();\n        this.comparisonVisible = false;\n        this.isComparing = false;\n        this.statusMessage = 'PDF selected. Choose the other document or compare the selected files.';\n    }\n\n    private disposeComparer(): void {\n        this.comparer?.destroy();\n        this.comparer = null;\n        if (this.comparisonDocuments) {\n            URL.revokeObjectURL(this.comparisonDocuments.original);\n            URL.revokeObjectURL(this.comparisonDocuments.modified);\n            this.comparisonDocuments = null;\n        }\n    }\n}\n"
    }
  ]
}