# FPdfTable

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/pdf-table](https://docs.univer.ai/zh-CN/reference/facade/pdf-table)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/pdf-table.md](https://docs.univer.ai/zh-CN/reference/facade/pdf-table.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/pdf-table.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/pdf-table.mdx)

---

Facade for one editable structured PDF table.

## Access

Access through:

* [`FPdfPage.getTables()`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page.md#gettables)
* [`FPdfPage.insertTable()`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page.md#inserttable)

## Inheritance

Extends [`FPdfPageElement`](https://docs.univer.ai/zh-CN/reference/facade/pdf-page-element.md). Its inherited members are available on this object.

## Example

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.insertTable({
  rowCount: 2,
  columnCount: 3,
  cellTexts: ['A', 'B', 'C'],
})
console.log(table.getRowCount()) // 2
console.log(table.getColumnCount()) // 3

table.resize(3, 4)
```

## Setup

Register [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) or a preset that includes it. In plugin mode, import `@univerjs-pro/pdfs/facade`. Additional methods below require their listed plugin packages. See [Facade setup](https://docs.univer.ai/zh-CN/guides/pdfs/getting-started/facade.md).

## `@univerjs-pro/pdfs`

### `FPdfTable.getCell`

Return a live table-cell Facade by zero-based coordinates.

```typescript
getCell(row: number, column: number): FPdfTableCell
```

**Parameters**

* `row` — Required. The zero-based row index.
* `column` — Required. The zero-based column index.

**Returns**

The live cell Facade.

**Throws**

If either coordinate is outside the current table.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.getTables()[0]
const cell = table?.getCell(0, 0)
console.log(cell?.getText())
```

**Types:** [`FPdfTableCell`](https://docs.univer.ai/zh-CN/reference/facade/pdf-table-cell.md)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-table.d.ts)

### `FPdfTable.getColumnCount`

Return the current table column count.

```typescript
getColumnCount(): number
```

**Returns**

The column count.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.getTables()[0]
console.log(table?.getColumnCount())
```

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-table.d.ts)

### `FPdfTable.getRowCount`

Return the current table row count.

```typescript
getRowCount(): number
```

**Returns**

The row count.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.getTables()[0]
console.log(table?.getRowCount())
```

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-table.d.ts)

### `FPdfTable.getTheme`

Return a detached table-theme descriptor.

```typescript
getTheme(): Readonly<IPdfTableTheme>
```

**Returns**

The current theme snapshot.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.getTables()[0]
console.log(table?.getTheme())
```

**Types:** [`IPdfTableTheme`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/types.d.ts) · [`Readonly`](https://unpkg.com/@typescript/typescript-darwin-arm64@7.0.2/lib/lib.es5.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-table.d.ts)

### `FPdfTable.resize`

Resize the table grid while preserving overlapping cells by position.

```typescript
resize(rowCount: number, columnCount: number): this
```

**Parameters**

* `rowCount` — Required. The positive new row count.
* `columnCount` — Required. The positive new column count.

**Returns**

This table Facade for chaining.

**Throws**

If either count is invalid or the table would exceed 10,000 cells.

If the table is stale or the durable command is rejected.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.getTables()[0]
if (table) {
  table.resize(3, 4)
}
```

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-table.d.ts)

### `FPdfTable.setTheme`

Replace the table theme and conditional style regions.

```typescript
setTheme(theme: IPdfTableTheme): this
```

**Parameters**

* `theme` — Required. The new table theme.

**Returns**

This table Facade for chaining.

**Throws**

If the table is stale or the durable command is rejected.

**Examples**

```ts
const pdf = univerAPI.getActivePdf()
const page = pdf.getPageByIndex(0)
const table = page.getTables()[0]
if (table) {
  const preset = univerAPI.getPdfTableThemePresets()[3]
  table.setTheme({
    styleId: preset.id,
    options: {
      firstRow: true,
    },
  })
}
```

**Types:** [`IPdfTableTheme`](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/types.d.ts)

**Package:** [`@univerjs-pro/pdfs`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/pdfs.md) · [Type definitions](https://unpkg.com/@univerjs-pro/pdfs@1.0.0-rc.0/lib/types/facade/f-pdf-table.d.ts)
