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 are zero-based. insertPage(index?) inserts at an index or appends 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 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()) : nullUse the typed getters when you need a specialized wrapper: 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()}Use remove() to delete an editable element. After removal, do not reuse the stale wrapper.
How is this guide?