Pages and Elements
Create PDF pages, enumerate editable elements, and control element geometry and stacking.
FPdf owns pages, and each FPdfPage exposes the durable editable overlays placed on that page.
Read and insert pages
Page indexes start at zero. insertPage(index?) inserts a page at the specified index, or appends a page when the index is omitted. An empty document uses A4 dimensions.
const pdf = univerAPI.getActivePdf()if (!pdf) { throw new Error('No active PDF')}const page = pdf.getPageByIndex(0) ?? pdf.insertPage()const pages = pdf.getPages()const samePage = pdf.getPageById(page.getId())Enumerate editable elements
getElements() returns the editable overlays in z-order. It does not return native objects from the imported PDF.
const elements = page.getElements()const [firstElement] = elementsconst sameElement = firstElement ? page.getElementById(firstElement.getId()) : nullFor a specialized wrapper, use the typed getters: getTextBoxes(), getParagraphs(), getLists(), getTables(), getImages(), getDividers(), and getAnnotations().
Transform and remove elements
Facade placement uses PDF points. Snapshot geometry returned by getData() uses core PDF units, so update placement through the Facade methods.
const [element] = page.getElements()if (element) { element .setPosition(36, 72) .setSize(288, 144) .setRotation(5) .setVisible(true) .setLocked(false) .bringToFront()}Call remove() to delete an editable element. After removal, do not reuse the stale wrapper.
How is this guide?