Optional ReadonlybeforeCompact host UI rendered below the standard toolbar, annotation toolbar, and built-in error banner, but above the sidebar/surface row.
Optional ReadonlydeleteHandles a sidebar deletion action for a one-based page number. Omit this to remove the page from the local document.
const viewer = usePdfrxViewer();
const deletePage = (pageNumber: number) => {
const pages = viewer?.document?.pages;
if (!pages || pages.length <= 1) return;
viewer.setPages(pages.filter((page) => page.pageNumber !== pageNumber));
};
return renderChrome({ deletePage });
Optional ReadonlyeditingDisables host-sensitive editing entry points without hiding the document. This covers open, page actions and drops, history buttons, download, annotation entry, and image drops.
Optional ReadonlyencodeProduces the PDF bytes downloaded by the standard Download button. The app
flushes active annotation text editing before calling this function and
still owns blob creation and browser download. Omit it to use
document.encodePdf({ mode: 'copy' }).
Optional ReadonlyinsertHandles files dropped into a thumbnail insertion slot. index is the
zero-based slot before which new pages should be inserted, from 0
through the current page count. Omit this for local page import.
const viewer = usePdfrxViewer();
const store = usePdfrxStore();
const insertFiles = async (files: File[], index: number) => {
const document = viewer?.document;
const engine = viewer?.engine;
if (!document || !engine) return;
const inserted: PdfPage[] = [];
for (const file of files) {
try {
const source = await openFileAsDocument(engine, file, {
passwordProvider: store.passwordProvider,
imageDecoder: store.imageDecoder,
});
inserted.push(...source.pages);
} catch (error) {
store.reportImportError(error, file.name);
}
}
const at = Math.max(0, Math.min(index, document.pages.length));
if (inserted.length > 0) {
viewer.setPages([
...document.pages.slice(0, at),
...inserted,
...document.pages.slice(at),
]);
}
};
return renderChrome({ insertFiles });
Optional ReadonlymoveHandles thumbnail reordering. fromPageNumber is one-based and toIndex
is the zero-based insertion slot in the pre-move page list. Omit this to
reorder the local document directly.
const viewer = usePdfrxViewer();
const movePage = (fromPageNumber: number, toIndex: number) => {
const pages = viewer?.document?.pages.slice();
if (!pages) return;
const from = fromPageNumber - 1;
if (toIndex === from || toIndex === from + 1) return;
const [moved] = pages.splice(from, 1);
if (!moved) return;
pages.splice(toIndex > from ? toIndex - 1 : toIndex, 0, moved);
viewer.setPages(pages);
};
return renderChrome({ movePage });
Optional ReadonlyonReceives an error thrown while preparing or starting a PDF download.
Optional ReadonlyopenHandles a file selected through the standard Open button. Omit this to replace the current document locally through the built-in store.
Optional ReadonlyrotateHandles a sidebar rotation action for a one-based page number. Omit this to replace the page with the locally rotated page.
const viewer = usePdfrxViewer();
const rotatePage = (pageNumber: number, delta: PdfPageRotationDelta) => {
const page = viewer?.document?.pages[pageNumber - 1];
if (page) viewer.setPage(pageNumber, page.rotatedBy(delta));
};
return renderChrome({ rotatePage });
Host overrides for the standard PdfrxViewerApp chrome.
Hosts can replace selected editing operations while retaining the built-in responsive layout and controls.