How stephanrauh/ngx-extended-pdf-viewer works
Project type and purpose
• This is an Angular “monorepo” workspace containing an open-source PDF-viewer library (ngx-extended-pdf-viewer), its CLI schematics, a showcase/demo application, plus build and test tooling.
• The core purpose is to wrap Mozilla’s pdf.js in an Angular module, add UI components, localization assets, and provide a ready-to-use npm package and demo site.
High-level file-structure analysis
• Root
– angular.json, tsconfig.json, package.json, build-tools/ (shell & Node scripts)
– compatibility-tests/ (Angular examples + Playwright)
• projects/ngx-extended-pdf-viewer/
– src/lib/ (components, services, options, dialogs, theme, toolbar, sidebar)
– assets/ (cmaps, fonts, locale files)
– schematics/ (ng-add generator)
– types/ (TypeScript declarations wrapping pdf.js)
• projects/showcase-schematics/ (schematic to scaffold docs pages)
• projects/showcase/
– src/app/ (Angular modules, routing, core, pages, shared components, assets)
– server.ts (SSR entrypoint for Node)
Key README insights
• Library wraps pdf.js and ships UI.
• Available at pdfviewer.net demonstrates features.
• Build-from-scratch walkthrough in how-to-build.md.
a. Main components
– Build Tools: shell scripts & Node scripts that compile library, schematics, showcase, run tests, publish to npm.
– PDF Viewer Library: Angular module + assets, schematics generator, TypeScript API, packaging config.
– pdf.js Core: third-party worker and API loaded at runtime by pdf-script-loader.service.
– Showcase Application: Angular SPA/SSR that imports the published library, routes pages, loads PDFs.
– Compatibility Tests: Angular demo apps + Playwright scripts verify cross-version behavior.
– CI/CD Pipeline: GitHub Actions, Dependabot, SonarCloud, npm registry, unpkg/CND.
b. Relationships & data flows
– Developer invokes “ng build” or build-tools scripts → compiles library + assets → outputs bundles.
– Packaging step → publishes to npm registry & unpkg CDN.
– Showcase and compatibility demos declare dependency on the npm package → on install they pull the bundles.
– At runtime the PDF Viewer component calls pdf.js via the script loader service → worker thread processes PDF → UI components render.
– CI triggers build → runs compatibility-tests (Angular examples + Playwright) → reports to SonarCloud → on success publishes new version.
c. Architectural patterns & principles
– Monorepo (Angular CLI workspace) for code sharing.
– Modular Angular architecture: library encapsulates PDF functionality behind a single NgModule.
– Schematics for zero-config setup (ng-add).
– Separation of concerns: core library vs. demo vs. tooling vs. tests.
– Automated CI/CD ensures package quality and versioning.
d. Technologies & frameworks
– Angular (components, modules, services, schematics)
– TypeScript declarations wrapping pdf.js APIs
– Node.js scripts & Bash for build orchestration
– Playwright for end-to-end compatibility testing
– GitHub Actions, SonarCloud for CI/CD
– npm registry & unpkg CDN for distribution