npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

flipbookengine

v1.2.7

Published

A modern, embeddable HTML flipbook engine for PDF-backed catalogs and digital publications.

Readme

FlipbookEngine

Current release: [email protected] (1.2.0 plus host fixes and options: showShare, pointToPage, hotspot classes, data and events, and setHotspots) adds YouTube/Vimeo hotspot embeds, reading-position resume, leaf edges, search highlight styles and named note colours, and fixes single/double switching and fullscreen page loss. 1.0.0 scope: Version 1.0.0 added the plugin contract, independent feature entrypoints, TOC runtime/embed APIs, and the complete open-source reader surface.

NPM Version License NPM Unpacked Size NPM Downloads

Live Demo & Playground ↗

FlipbookEngine is a modern, lightweight, and embeddable HTML flipbook viewer for PDF-backed catalogs, brochures, and digital publications. Written in TypeScript, it features single-page and spread modes, a thumbnail rail, smooth zoom/pan, full internationalization (i18n), and robust theme customization.

Highlights

  • Dual-Mode Layout: Seamlessly switches between single-page (mobile-optimized) and spread (book/catalog layout) modes.
  • Rich Interaction: Built-in thumbnail navigation rail, smooth zoom & pan, and HTML5 fullscreen support.
  • Media & Autoplay: Configurable page-flip sound effects and automated slideshow presentation with Autoplay.
  • Theme Engine: Styled with compiled CSS and CSS Custom Properties, featuring full support for light/dark modes (auto-responsive to Bootstrap 5 or tailorable per instance).
  • Multi-Language (i18n): Out-of-the-box support for English (en) and Turkish (tr) with customizable overrides.
  • Framework Wrappers: Direct React and Vue wrapper exports for seamless modern integration.
  • Progressive PDF Rendering: PDF pages render on demand with bounded concurrency and an instance-local LRU cache, keeping large documents responsive.
  • Localized Sharing: The toolbar includes a Share control that opens the native share sheet or copies the current page URL; enable deepLink: true for shareable page navigation.
  • Host-Managed Bookmarks: The toolbar can toggle the current page bookmark; hosts can initialize and persist zero-based bookmark indexes through the public API and bookmarkChange event.
  • Host-Managed Notes: The localized notes toolbar opens an inline editor; hosts can initialize, update, and persist page notes through the public API and noteChange event without coupling the viewer to a storage backend.
  • Client-Side PDF Search: Extracts and searches PDF text on demand with localized snippets and normalized text-rectangle highlighting.
  • Interactive Hotspots: Adds normalized page overlays with accessible plain-text popups and optional links.
  • Reading Position: Reopens a document at the last page read on the device, or at a page the host saved; the double-page layout shows the spread that contains it.
  • Book Depth: Leaf edges beside the open spread follow the page count and the reading position, and scale with resizing and zoom.
  • Note Colours: A colour palette for coordinate notes is on by default; hosts can name each colour, and the name shows on hover.

Backend text layers for image books

WebP/JPEG books can consume persistent text extracted by the host backend. Supply optional textLayerProvider(pageIndex, signal) alongside searchProvider. The reader loads at most the current page and its neighbors, validates normalized run coordinates, and overlays transparent selectable text without downloading the PDF. Enable More actions > Select text, or call setTextSelection(true); Escape returns to navigation mode. Pointer selection is isolated from flip gestures and note long-press. Toolbar/keyboard page navigation stays available.

Extraction, OCR, indexing, authorization and persistence belong to the host, not the browser. A text layer is fixed-layout accessibility/selection data, not EPUB reflow. See backend text layer contract and API reference. These APIs are available from npm 1.0.2.

Installation

Install via npm:

npm install flipbookengine

pdfjs-dist is a production dependency of FlipbookEngine. It is installed by npm, but is deliberately excluded from the FlipbookEngine bundle so applications can deduplicate, cache, and upgrade PDF.js independently.

Quick Start

npm and Bundlers

Configure the PDF.js worker in the consuming application. The ?url suffix is supported by Vite and other modern bundlers that emit imported assets.

import { FlipbookEngine } from 'flipbookengine';
import 'flipbookengine/styles.css';
import pdfWorkerSrc from 'pdfjs-dist/build/pdf.worker.mjs?url';

const engine = new FlipbookEngine('#viewer', {
  allowDownload: true,
  showThumbs: false,
  primaryColor: '#7367f0',
  theme: 'auto',
  locale: 'en',
  pdfWorkerSrc,
  pdfRenderCacheSize: 32,
  pdfPageMode: 'auto',
  background: {
    light: { color: '#f8fafc', image: '/branding/light.webp', size: 'cover' },
    dark: { color: '#0f172a', image: '/branding/dark.webp', size: 'cover' }
  }
});

await engine.init('/files/catalog.pdf');

Passing pages remains optional. When omitted, FlipbookEngine creates the page structure from pdfUrl, renders the first page before init resolves, and prefetches the next page. Additional pages render as they become visible or are selected. In pdfPageMode: 'auto' (the default), ISO A3 landscape pages are normalized into two logical pages; use 'single' to keep every PDF page intact or 'split' to split every landscape PDF page.

pdfRenderCacheSize controls the per-instance LRU cache (default 32, set to 0 to disable it).

Browser CDN

Use the ESM build with an import map for PDF.js. The worker must be served from a URL your site permits in its Content Security Policy.

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/flipbook-engine.css" />
<div id="viewer" style="width: 100%; height: 600px;"></div>

<script type="importmap">
{
  "imports": {
    "pdfjs-dist": "https://unpkg.com/[email protected]/build/pdf.min.mjs"
  }
}
</script>
<script type="module">
  import { FlipbookEngine } from 'https://unpkg.com/[email protected]/dist/flipbook-engine.js';

  const engine = new FlipbookEngine('#viewer', {
    pdfWorkerSrc: 'https://unpkg.com/[email protected]/build/pdf.worker.min.mjs'
  });

  await engine.init('/files/catalog.pdf');
</script>

React

import React, { useRef } from 'react';
import { Flipbook, FlipbookRef } from 'flipbookengine/react';
import 'flipbookengine/styles.css';

function CatalogViewer() {
  const flipbookRef = useRef<FlipbookRef>(null);

  const handleNextPage = () => {
    flipbookRef.current?.goToPage(flipbookRef.current.getCurrentPage() + 1);
  };

  return (
    <Flipbook
      ref={flipbookRef}
      pdfUrl="/files/catalog.pdf"
      pages={[
        { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
        { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
      ]}
      allowDownload={true}
      showThumbs={true}
      primaryColor="#7367f0"
    />
  );
}

Vue 3

<template>
  <Flipbook
    pdfUrl="/files/catalog.pdf"
    :pages="pages"
    :allowDownload="true"
    :showThumbs="true"
    primaryColor="#7367f0"
  />
</template>

<script setup>
import { Flipbook } from 'flipbookengine/vue';
import 'flipbookengine/styles.css';

const pages = [
  { kind: 'cover', pageNumber: 1, normal: '/img/1.jpg', low: '/img/1-low.jpg', thumb: '/img/1-thumb.jpg' },
  { kind: 'spread', pageNumbers: [2, 3], normal: '/img/2-3.jpg', low: '/img/2-3-low.jpg', thumb: '/img/2-3-thumb.jpg' }
];
</script>

Both wrappers send only changed options on a re-render, accept every engine option as a prop, and expose the engine for events; server-rendered apps load them on the client only. See Framework integrations.

Iframe embedding

For a viewer hosted in an iframe, connect the bridge from the iframe document and allow only the parent origin:

const engine = new FlipbookEngine('#viewer', { showThumbs: false });
engine.connectEmbed({
  allowedOrigins: ['https://catalog.example.com']
});
await engine.init('/files/catalog.pdf');

From the parent page, use the controller exported by the package:

import { createFlipbookEmbedController } from 'flipbookengine';

const controller = createFlipbookEmbedController(
  document.querySelector('#catalog-frame'),
  { targetOrigin: 'https://viewer.example.com' }
);
await controller.goToPage(2);

Always configure explicit origins for cross-origin embeds. The bridge supports page navigation, zoom, single mode, option updates, fullscreen, TOC read/update, search, state queries, and event forwarding.

Migration Notes

Upgrading from 0.3.x to 0.4.0 keeps the public engine methods intact. The release isolates state per engine instance, makes wrapper updates lifecycle-safe, and scopes viewer markup to its container. If host CSS or automation selected the former fixed viewer IDs, migrate those selectors to the instance classes documented in the theming guide. PDF-backed consumers should configure pdfWorkerSrc; image-only viewers do not expose a download control.

For 0.5.0 behavior, see the 0.5.0 migration guide. PDF-backed viewers now render on demand; callers should use progress and error events for rendering telemetry.

For the 1.0.0 migration and the 0.x compatibility boundary, see the 1.0.0 migration guide.

Public API Reference

The FlipbookEngine class exposes the following public methods:

  • init(pdfUrl: string, imageList?: FlipbookPageAsset[]): Initializes the viewer and loads the flipbook with pages.
  • goToPage(pageIndex: number): Navigates programmatically to a 0-based page index.
  • getCurrentPage(): Returns the 0-based index of the currently active page.
  • getTotalPages(): Returns the total number of pages.
  • getZoom(): Returns the current zoom level (default is 1).
  • setZoom(zoomLevel: number): Programmatically sets the zoom level (accepts values between 0.5 and 5).
  • setSingleMode(isSingle: boolean): Programmatically toggles between single-page mode (true) and double-page spread mode (false).
  • toggleFullscreen(): Programmatically toggles fullscreen mode.
  • updateOptions(options: Partial<FlipbookEngineOptions>): Updates instance options at runtime.
  • setLocale(locale: string, messages?: PartialFlipbookMessages | Record<string, PartialFlipbookMessages>): Updates the locale programmatically and optionally overrides messages for that locale.
  • getPageUrl(pageIndex = getCurrentPage()): Returns a shareable URL for a 0-based page index.
  • sharePage(pageIndex = getCurrentPage()): Opens the native share dialog or copies the page URL to the clipboard. The toolbar exposes this behavior through a localized Share button.
  • getBookmarkedPages(): Returns the sorted zero-based bookmark indexes.
  • isBookmarked(pageIndex = getCurrentPage()): Checks whether a page is bookmarked.
  • setBookmark(pageIndex, bookmarked) / toggleBookmark(pageIndex): Updates bookmark state and emits bookmarkChange; hosts can persist the event payload.
  • getNotes() / getNote(pageIndex): Reads host-managed page notes.
  • setNote(pageIndex, note) / clearNote(pageIndex): Updates notes and emits noteChange; empty notes are removed. The toolbar editor is intentionally host-storage agnostic, so a backend can persist each event later.
  • destroy(keepContainer = false): Tears down the instance and listeners; when true, keeps the container markup for an immediate reinitialization.

Subscribing to Events

You can subscribe to events using .on(). PDF-backed initialization reports loading/rendering progress and emits a structured error event when loading or rendering fails:

const unsubscribe = engine.on('pageChange', ({ currentPage, totalPages, isSingle }) => {
  console.log('Page Changed:', currentPage, 'Total:', totalPages);
});

// To unsubscribe:
unsubscribe();

Supported events: init, progress, pageChange, zoomChange, singlePageModeChange, thumbsToggle, tocToggle, orientationChange, deepLinkChange, bookmarkChange, noteChange, searchChange, searchProgress, hotspotActivate, hotspotOpen, hotspotClose, annotationActivate, error, destroy.

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | showArrows | boolean | true | Shows the previous/next navigation arrows. | | showToc | boolean | false | Shows the table of contents panel when toc entries are supplied. | | toc | FlipbookTocEntry[] | [] | Host-provided chapter/category entries with zero-based page indexes. | | soundEnabled | boolean | true | Enables page turning sound effect. | | soundUrl | string | 'https://.../page-flip.mp3' | URL of the audio file. | | autoPlayInterval| number | 3000 | Autoplay page duration in milliseconds. | | flippingTime | number | 1000 | Duration of the page turn animation in milliseconds; automatically disabled when reduced motion is preferred. | | maxShadowOpacity | number | 0.5 | Maximum opacity of the shadow during page turn (0 to 1). | | whiteLabel | boolean | false | Hides the "Powered by FlipbookEngine" watermark. | | pdfWorkerSrc | string | - | URL of the PDF.js worker emitted or hosted by the consuming application. | | pdfRenderConcurrency | number | 3 | Maximum number of PDF pages rendered concurrently when on-demand pages are requested. | | pdfRenderCacheSize | number | 32 | Maximum number of rendered PDF page images retained per engine instance (LRU); 0 disables caching. | | pdfPageMode | 'auto' \| 'single' \| 'split' | 'auto' | Controls PDF page splitting: A3 landscape pages are split automatically, all landscape pages can be split explicitly, or splitting can be disabled. | | background | FlipbookBackgrounds \| null | null | Optional light/dark viewer backgrounds with color, image, size, position, and repeat settings. image accepts a URL (PNG, JPG, SVG, data URL), a CSS gradient or inline <svg> markup. | | startPage | number | - | Zero-based page to open at, for example the last page the host saved from pageChange. Wins over rememberPage. | | rememberPage | boolean \| string | true | Reopens at the last page read on this device (localStorage). A string is used as the document key; otherwise the PDF URL or first page URL is the key. false turns it off. | | searchHighlightStyle | 'highlight' \| 'underline' \| 'bubble' | 'highlight' | How search matches are marked on the page: a semi-transparent marker over the word, a 3px line below it, or a soft rounded bubble around it. | | noteColors | FlipbookNoteColor[] \| string[] \| boolean | true | Colour palette in the note editor. true uses five defaults, false hides it, or pass { value, label? } items. | | notePinSize | number | 10 | Diameter in px of coordinate-note pins. | | deepLink | boolean | false | Keeps the active page synchronized with a ?page= URL parameter. The localized toolbar Share control uses this URL format. | | showShare | boolean | true | Shows the Share command. false hides it, for example for readers without share permission; sharePage() still works for the host. | | bookmarks | number[] | [] | Initial zero-based bookmarked page indexes; the host owns persistence. | | notes | Record<number, string> | {} | Initial page notes keyed by zero-based page index; the notes toolbar edits them while the host owns persistence. | | hotspots | FlipbookHotspot[] | [] | Normalized (0..1) page overlays with info/media/gallery/commerce popup content and optional links. | | annotations | FlipbookAnnotation[] | [] | Host-managed page note markers with normalized coordinates and plain-text popup content. | | onShare | (url: string) => void | null | Optional callback invoked after the toolbar shares or copies the generated page URL. |

PDF page formats

PDF.js page dimensions are detected at runtime, so portrait A4, landscape A4, and other page ratios are supported without a fixed size preset. A3 landscape pages are split into left/right logical pages when pdfPageMode is 'auto' or 'split'; the halves are presented as an A4-like spread in double-page mode.

Styling and Theming

Content Security Policy. The package works under a nonce-only style-src (for example style-src 'self' 'nonce-...') with no unsafe-inline. It never writes style attributes or cssText; dynamic styles are assigned per property through the CSSOM, which CSP allows. Load flipbook-engine.css as a normal stylesheet (with your nonce on an inline <style> if you inline it).

FlipbookEngine features fully custom-property-based styling compatible with modern styling systems.

Global CSS Variables

:root {
  --flipbook-bg-main: #f3f6fb;
  --flipbook-bg-panel: #172033;
  --flipbook-accent: #7367f0;
  --flipbook-thumbrail-bg: #0f172a;
}

Performance & Bundle Metrics

FlipbookEngine is designed for responsive rendering with hardware-accelerated CSS 3D transforms and a lightweight DOM update path.

Package Size and PDF.js

FlipbookEngine does not bundle PDF.js or its worker. pdfjs-dist remains a normal npm dependency, while the host application supplies pdfWorkerSrc. This keeps the FlipbookEngine package smaller and lets the application control PDF.js versioning, caching, CSP, and worker hosting.

  • Core engine: excludes PDF.js and the PDF worker.
  • Styles: distributed as flipbookengine/styles.css.
  • PDF rendering: enabled by configuring pdfWorkerSrc as shown above.

Performance Highlights

  • Hardware Accelerated: Uses CSS-based 3D transformations (transform: rotateY, translateZ) without a WebGL runtime.
  • Progressive Image Quality: Loads low-quality page assets first and upgrades visible pages to their normal-quality source through IntersectionObserver.
  • On-demand PDF Rendering: Large PDFs create lightweight placeholders first; the current page and next page render before or during navigation.
  • Bounded PDF Rendering: PDF pages are rendered with configurable concurrency (pdfRenderConcurrency, default 3) and can be cancelled when an initialization is superseded or destroyed.
  • PDF Render Cache: A bounded per-instance LRU cache (pdfRenderCacheSize, default 32) avoids repeated canvas work while preventing unbounded memory growth.

FlipbookEngine vs. The Industry

When choosing a flipbook library, here is how we compare to other solutions:

  • Legacy Libraries (e.g., Turn.js): Turn.js is over a decade old, relies on jQuery, and lacks native PDF support. FlipbookEngine uses a modern framework-agnostic stack (Vanilla/React/Vue), TypeScript, and has built-in PDF.js integration.
  • Heavy 3D Plugins (e.g., DearFlip, Real3D): Many 3D plugins use WebGL, which can increase runtime overhead on mobile. FlipbookEngine uses StPageFlip with CSS 2D/3D transforms and no WebGL runtime.
  • Closed SaaS Platforms (e.g., Issuu, Heyzine): These charge high monthly fees and lock your data on their servers. FlipbookEngine gives you 100% control to host and embed directly in your own code (AGPL-3.0).

Acknowledgments

A special thanks to the incredible team behind Serenity. FlipbookEngine's reactive UI layer is powered by domwise. Coupled with @preact/signals-core, this keeps the UI update path small without requiring a traditional Virtual DOM runtime.


Release scope

FlipbookEngine ships an AGPL open-source viewer package and maintains a separate closed-source commercial backend roadmap.

Open-source v1.0.0 (AGPL viewer)

The npm package is an embeddable, framework-agnostic PDF viewer. The following client-side reader capabilities are included in the open-source v1.0.0 release:

  • Table of Contents (Index): Interactive navigation to chapters or product categories.
  • Page Notes & Annotations: Reader notes and bookmarks stored by the host application.
  • Full-Text PDF Search: Client-side text extraction and highlighting without blocking the viewer.
  • Interactive Hotspots & Pop-ups: Custom overlays for media, galleries, and commerce links.
  • Deep Linking & Social Share: URLs that address specific pages or spreads.

The open-source viewer continues to use PDF.js as an external npm dependency and does not require a backend renderer.

The v1.0.0 release also defines the framework-agnostic plugin contract. The rendering core stays small while TOC, notes, bookmarks, annotations, search, hotspots, and sharing can be installed as optional plugins. Analytics is not shipped as an official open-source plugin; hosts can consume the documented events or use a private commercial adapter. See Plugin architecture.

Plugin usage and activation

Version 1.0.0 keeps the all-in-one entry point for existing applications and adds optional, tree-shakeable feature adapters. A plugin is active only when it is supplied in the constructor or installed at runtime. Omitting an adapter keeps it inactive.

import { FlipbookEngine } from 'flipbookengine/core';
import { notesPlugin } from 'flipbookengine/plugins/notes';
import { bookmarksPlugin } from 'flipbookengine/plugins/bookmarks';

const engine = new FlipbookEngine('#viewer', {
  plugins: [notesPlugin, bookmarksPlugin]
});

await engine.callPluginApi('notes', 'set', 0, 'Review this page');
console.log(engine.getPluginNames());

Disable or remove a feature at runtime with uninstallPlugin(name). This removes the plugin APIs, toolbar/panel contributions, event subscriptions, and cleanup callbacks. Re-enable it with installPlugin(plugin):

engine.uninstallPlugin('notes');
engine.installPlugin(notesPlugin);

The official notes, bookmarks, TOC, search, annotations, hotspots, share, and deep-link adapters expose namespaced APIs. Their UI is still controlled by the host/all-in-one viewer options; custom plugins may additionally register toolbar buttons and panels through the plugin contract. Analytics is not included as an official open-source adapter.

0.8.0 to 1.0.0 compatibility boundary

Version 1.0.0 is the first stable compatibility boundary. The 0.8.0 line was alpha/beta and does not provide a rollback or compatibility guarantee.

  • The documented all-in-one import and engine options remain available.
  • Imports from undocumented internal src/* or generated dist/* files are not supported; move to flipbookengine/core, flipbookengine/plugins, or the documented feature subpaths.
  • Optional adapters are explicit: pass them through plugins, call installPlugin() to enable, and uninstallPlugin() to disable and clean up their APIs, UI contributions, and event listeners.
  • TOC runtime/embed APIs and expanded hotspot media/gallery/commerce fields are new 1.0 APIs; existing host-managed data remains the source of truth.
  • Image/WebP text search remains unsupported; PDF mode is required unless the host supplies server-generated text metadata.

See the complete 1.0.0 migration guide before upgrading from 0.8.0.

Commercial edition (closed-source backend)

The commercial roadmap is separate from the AGPL package and is intended for a separate backend project. It will provide licensed server-side capabilities, including:

  • Backend PDF rendering: Secure, server-side rendering and caching for protected documents and high-volume workloads.
  • Protected partial downloads: Server-generated page selections and authorization-aware download policies.
  • AI-assisted document features: Backend indexing, catalog search, and Chat with Docs integrations.
  • Enterprise identity and provenance: OIDC, auditability, tenant controls, and deployment integration.

These backend renderer and enterprise features will not be included in the public flipbookengine npm package; they will be delivered under the commercial license.


Licensing

FlipbookEngine is distributed under a dual-license model:

  • Open Source: GNU Affero General Public License v3.0 or later (see LICENSE).
  • Commercial: For use in closed-source projects, proprietary SaaS platforms, or agency client deliveries (see COMMERCIAL_LICENSE.md).

For commercial licenses and inquiries, contact: [email protected]

Client-side PDF search

When initialized with a PDF URL, search(query) extracts text through PDF.js without rendering every page. It returns page-level matches and snippets, updates the search toolbar panel, and overlays precise normalized rectangles over matching text when PDF.js exposes text geometry. Search results use a zero-based pageIndex for API navigation and a one-based pageNumber for display.

const results = await engine.search('catalog', { caseSensitive: false, maxResults: 50 });
engine.goToPage(results[0]?.pageIndex ?? 0);
engine.clearSearch();

Search is unavailable for image-only page lists because those assets do not contain extractable PDF text or text geometry. For image mode, applications that need search/highlights should generate page text and normalized coordinates on the server and pass the resulting page metadata as a host-side feature; the open-source viewer does not OCR raster images. The iframe controller exposes the same operation with search, clearSearch, and getSearchResults.

Matches are marked with searchHighlightStyle: 'highlight' (default) paints a semi-transparent marker over the word so the text stays readable, 'underline' draws a 3px line below the word and 'bubble' draws a soft, transparent rounded bubble around it. All three use the --flipbook-search-highlight colour (default #e5484d). Marks are drawn only when a result has highlights: built-in PDF search computes them from the PDF text geometry; a custom searchProvider must return normalized { x, y, width, height } rectangles for each match, otherwise only the result list and page navigation are shown.

const engine = new FlipbookEngine('#viewer', { searchHighlightStyle: 'bubble' });
engine.updateOptions({ searchHighlightStyle: 'underline' });

Hotspots also take className (extra classes on the .bk-hotspot button) and data (written as data-* attributes), so a host can style and identify its own hotspots, for example { className: 'sl-video', data: { 'item-id': 42 } }. engine.pointToPage(clientX, clientY) turns a viewport point into { pageIndex, x, y } (0..1 on that page) or null, for placing hotspots or markers where the reader clicked. Stable class names for host styling are listed in docs/theming.md.

Reading position

The viewer remembers the last page read for each document on the device and opens there next time: in single-page mode on that page, in double-page mode on the spread that contains it (page 84 opens as 84-85). The key is the PDF URL or the first page image URL; pass a string to rememberPage when the same document can be served from different URLs, or false to turn it off. A ?page= deep link always wins.

To follow the reader across devices, store the page on the server and pass it back as startPage, which wins over the device copy:

const engine = new FlipbookEngine('#viewer', { rememberPage: 'catalog-42', startPage: savedPageIndex });
engine.on('pageChange', ({ currentPage }) => saveLastPage('catalog-42', currentPage));

Book depth (leaf edges)

In double-page layout thin leaf edges appear beside the spread. Their total thickness grows with the page count; the left side shows the pages already read and the right side the pages still to come, so on page 10 of a 160-page book the right stack is about 15 times the left one. They follow page turns, resizing and zoom. Tune them with --flipbook-page-edge-max (largest thickness, default 18px, 12px on small screens), --flipbook-page-edge-color and --flipbook-page-edge-line, or hide them with .bk-page-stack { display: none; }.

Note colours

The note editor shows a colour palette (on by default). Name the colours from the host or backend and the name appears in a small bubble on hover and keyboard focus; unnamed colours read "Group 1", "Group 2" (Turkish "1. Grup"). The saved annotation carries the chosen color value.

const engine = new FlipbookEngine('#viewer', {
  noteColors: [
    { value: '#e5484d', label: 'Exam' },
    { value: '#0091ff', label: 'Homework' },
    { value: '#30a46c', label: 'Read later' }
  ]
});

Interactive hotspots

Hosts can provide normalized (0..1) page coordinates for lightweight links and pop-ups:

const engine = new FlipbookEngine('#viewer', {
  hotspots: [{ id: 'product-42', pageIndex: 3, x: 0.60, y: 0.25, width: 0.25, height: 0.18, label: 'Product details', content: 'Open the product details page.', href: '/products/42' }]
});
engine.on('hotspotOpen', ({ hotspot }) => console.log('open', hotspot.id));
engine.on('hotspotClose', ({ hotspot }) => console.log('close', hotspot.id));

Hotspots support kind: 'info' | 'media' | 'gallery' | 'commerce'. media takes type: 'image' | 'video' | 'audio' | 'embed'; embed (or a YouTube/Vimeo link given as video) plays YouTube and Vimeo inside the popup through youtube-nocookie.com or Vimeo with do-not-track, in a sandboxed, lazily loaded iframe. Other embed hosts are shown as a link, never framed.

hotspots: [{ id: 'lesson', pageIndex: 12, x: .1, y: .4, width: .5, height: .25, label: 'Lesson video', kind: 'media',
  content: 'Watch the explanation.', media: { type: 'embed', src: 'https://www.youtube.com/watch?v=VIDEO_ID&t=90' } }]

A hotspot can render a single image/video/audio preview through media, a selectable image gallery through gallery, and a safe external/product destination through href. Content remains plain text. Links accept only relative, http(s), mailto and tel URLs; javascript:, data: and other schemes are dropped by the viewer, but hosts should still validate server-provided URLs. Use activateHotspot(id) and closeHotspot() for programmatic control, and setHotspots(list) (or updateOptions({ hotspots })) to replace the hotspots on every page at runtime.

Page annotations

Host uygulamaları, kullanıcı notunu sayfa üzerindeki normalize koordinata bağlamak için annotations seçeneğini kullanabilir. Marker tıklaması popup açar ve annotationActivate olayı yayınlanır. Bu sözleşme şimdilik host-managed'dir; annotation kayıtlarının backend koordinatlarına taşınması tüketici uygulamanın sorumluluğundadır.

const engine = new FlipbookEngine('#viewer', {
  annotations: [{ id: 'note-1', pageIndex: 4, x: .42, y: .36, text: 'Review pricing' }]
});