How pneves-ciandt/ngx-extended-pdf-viewer works
Project type and purpose
• This is an Angular component library (“ngx-extended-pdf-viewer”) that wraps Mozilla’s pdf.js into an Angular-friendly viewer plus UI.
• It provides an npm-publishable library (under projects/ngx-extended-pdf-viewer) with schematics, assets, and tests.
• Key use cases: embed a PDF viewer into Angular apps, supply a consistent UI, support translations, themes, and advanced features (annotations, find, print, etc.).
High-level file-structure analysis
• Root configuration & scripts:
• angular.json, tsconfig.json, .prettierrc, jest.config.ts, GitHub workflow files (.github/)
• Custom scripts (e.g., add-version-number, extract-versions.js) for build/versioning
• Library source under projects/ngx-extended-pdf-viewer/:
• src/lib: Angular components, services, pipes, modules, event definitions
• assets: cmaps, fonts, locale FTL files, pdf.worker/ sandbox bundles
• schematics: ng-add recipe to scaffold example apps
• theme, toolbar, sidebar, dialogs: organized feature folders
• Tests & compatibility:
• Unit tests (Jest) in src/lib and toolbar subfolders
• End-to-end compatibility tests under compatibility-tests/ (Angular16, Angular17 demos, Playwright scripts)
• CI, publishing & security:
• GitHub Actions config (.github/) to run builds, tests, SonarCloud analysis
• sbom.json, dependabot.yml, sonar-cloud.yml, security.md
• Build output & packaging:
• ng-package.json and ng-package.prod.json control ng-packagr
• Public API surface in public_api.ts
• package.json / package-lock.json for npm
README insights
• Confirms purpose: “Bringing Mozilla’s pdf.js to the Angular world”
• Points to live demos (pdfviewer.net) and build instructions (how-to-build.md)
• Emphasizes library distribution via npm/unpkg
a. Main components
• Developer workspace / repo (source code + scripts + configs)
• Angular library module (ngx-extended-pdf-viewer) comprising:
• Angular UI components (toolbar, sidebar, dialogs)
• Services & event bus (pdf- script-loader, notification, CSP policy)
• Schematics (ng-add recipe)
• Assets package (cmaps, fonts, locale FTLs, pdf.worker & sandbox bundles)
• Build & test pipeline
• Angular CLI (ng build, ng-packagr) → bundles (ESM, UMD)
• Jest (unit tests)
• Playwright & Docker (compatibility-tests)
• GitHub Actions + SonarCloud + Dependabot
• Consumers
• Angular applications importing the library
• npm registry / unpkg CDN serving bundles
• External dependencies
• pdf.js (packaged assets)
• Angular framework
• rxjs, Zone.js, etc.
b. Relationships and interactions
• Developer commits → GitHub Actions triggers → build & test → if green → publish bundles to npm
• Consumer app (frontend) imports module → loads assets (pdf.worker, fonts, cmaps) from library package → Angular components render PDF
• Angular component communicates with web worker (pdf.worker-X.mjs) for parsing/rendering → returns canvas/svg/text layers → UI components subscribe to events via pdf-event-bus
c. Architectural patterns & principles
• Modular architecture: UI features (toolbar, sidebar, dialogs) separated into feature modules
• Service-oriented: central PdfScriptLoaderService, EventBus, NotificationService
• Asset-bundle separation: large binary/text assets separated from TS code for tree-shaking
• Schematics for code generation (ng-add)
• CI/CD as code (GitHub Actions, Docker demos)
d. Key technologies/frameworks
• Angular CLI + ng-packagr
• TypeScript, Jest for unit testing
• Playwright + Docker for compatibility e2e tests
• pdf.js (pdf.worker & sandbox modules)
• GitHub Actions, SonarCloud, Dependabot