PdfLayoutFormat
6 Jul 20266 minutes to read
Represent the layout format class for pagination
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the first page
let page: PdfPage = document.getPage(0);
// Create an instance of list item collection by passing the string array
let items: PdfListItemCollection = new PdfListItemCollection([‘Excel’, ‘Power’, ‘Point’, ‘Word’, ‘PDF’]);
// Create a new PDF ordered list
let list: PdfOrderedList = new PdfOrderedList(items);
// Create an instance for PDF layout format
let layout: PdfLayoutFormat = new PdfLayoutFormat();
// Set the layout format
layout.break = PdfLayoutBreakType.fitPage;
layout.layout = pdfLayoutType.paginate;
// Draw the items using specified bounds and layout format
list.draw(page, {x: 0, y: 20}, layout);
// Save the document
document.save(‘output.pdf’);
// Destroy the document
document.destroy();
## Properties
### Get break [`PdfLayoutBreakType`](./pdfLayoutBreakType)
Gets the layout break type of the page.
### Set break `void`
Sets the layout break type for the page.
| Parameter | Type | Description |
|------|------|-------------|
| value | [`PdfLayoutBreakType`](./pdfLayoutBreakType) | The layout break type to set for the page. |
### Get columnGutter `number`
Gets the gutter (spacing) between columns.
```typescript
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a layout format with multi-column support
let layout: PdfLayoutFormat = new PdfLayoutFormat();
layout.layout = PdfLayoutType.paginate;
layout.break = PdfLayoutBreakType.fitPage;
layout.columns = 2;
layout.columnGutter = 15;
// Get the column gutter
let gutter: number = layout.columnGutter;
// Create a text element
let element: PdfTextElement = {
text: 'Hello world drawn using layout format with multiple columns support in PDF.',
font: document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular),
brush: new PdfBrush({ r: 0, g: 0, b: 0 }),
layoutFormat: layout
};
// Draw the text element using a specific point
const result = page.drawTextElement(element, { x: 50, y: 100 });
// Save the PDF document
document.save('output.pdf');
// Destroy the document
document.destroy();
Set columnGutter void
Sets the gutter (spacing) between columns.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a layout format with multi-column support
let layout: PdfLayoutFormat = new PdfLayoutFormat();
layout.layout = PdfLayoutType.paginate;
layout.break = PdfLayoutBreakType.fitPage;
layout.columns = 2;
layout.columnGutter = 15;
// Create a text element
let element: PdfTextElement = {
text: 'Hello world drawn using layout format with multiple columns support in PDF.',
font: document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular),
brush: new PdfBrush({ r: 0, g: 0, b: 0 }),
layoutFormat: layout
};
// Draw the text element using a specific point
const result = page.drawTextElement(element, { x: 50, y: 100 });
// Save the PDF document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | number |
The gutter (spacing) between columns. |
Get columns number
Gets the number of columns used for pagination.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a layout format with multi-column support
let layout: PdfLayoutFormat = new PdfLayoutFormat();
layout.layout = PdfLayoutType.paginate;
layout.break = PdfLayoutBreakType.fitPage;
layout.columns = 2;
// Get the number of columns
let columns: number = layout.columns;
// Create a text element
let element: PdfTextElement = {
text: 'Hello world drawn using layout format with multiple columns support in PDF.',
font: document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular),
brush: new PdfBrush({ r: 0, g: 0, b: 0 }),
layoutFormat: layout
};
// Draw the text element using a specific point
const result = page.drawTextElement(element, { x: 50, y: 100 });
// Save the PDF document
document.save('output.pdf');
// Destroy the document
document.destroy();Set columns void
Sets the number of columns used for pagination.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a layout format with multi-column support
let layout: PdfLayoutFormat = new PdfLayoutFormat();
layout.layout = PdfLayoutType.paginate;
layout.break = PdfLayoutBreakType.fitPage;
layout.columns = 2;
// Create a text element
let element: PdfTextElement = {
text: 'Hello world drawn using layout format with multiple columns support in PDF.',
font: document.embedFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular),
brush: new PdfBrush({ r: 0, g: 0, b: 0 }),
layoutFormat: layout
};
// Draw the text element using a specific point
const result = page.drawTextElement(element, { x: 50, y: 100 });
// Save the PDF document
document.save('output.pdf');
// Destroy the document
document.destroy();| Parameter | Type | Description |
|---|---|---|
| value | number |
The number of columns to set. |
Get layout PdfLayoutType
Gets the layout type of the page.
Set layout void
Sets the layout type of the page.
| Parameter | Type | Description |
|---|---|---|
| value | PdfLayoutType |
The layout type of the page. |
Get paginateBounds Rectangle
Gets the paginate bounds of the page.
Set paginateBounds void
Sets the paginate bounds for the page.
| Parameter | Type | Description |
|---|---|---|
| value | Rectangle |
The paginate bounds to set for the page. |
Get usePaginateBounds boolean
Gets whether to use paginate bounds for pagination.