Syncfusion AI Assistant

How can I help you?

PdfListItemCollection

21 Apr 202613 minutes to read

Represents a collection of list items that can be drawn on a PDF page.

// 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']);
// Create a new PDF ordered list
let list: PdfOrderedList = new PdfOrderedList(items);
// Draw the list items
list.draw(page, {x: 0, y: 20});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

Get count number

Gets the count of the list item collection.

Methods

add

Adds a PdfListItem to the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create an instance of ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Add the items to list item collection by passing the array of products
let item: PdfListItem = new PdfListItem('Hello World');
// Add the item to the list
list.items.add(item);
// Draw the list on the page at specified coordinates and dimensions
list.draw(page, {x: 20, y: 50, width: 500, height: 700});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
item PdfListItem The list item to be added to the collection.

Returns void

add

Adds a PdfListItem to the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create an instance of PdfOrderedList
let list: PdfOrderedList = new PdfOrderedList();
// Create a new item by passing a string value
let item: PdfListItem = new PdfListItem('Hello World');
// Add the item to the list with a specified text indent
list.items.add(item, 40);
// Draw the list on the page at specified coordinates and dimensions
list.draw(page, {x: 20, y: 50, width: 500, height: 700});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
item PdfListItem The list item to be added to the collection.
itemIndent number The indent of the list item

Returns void

at

Retrieves the PdfListItem at the specified index in the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Accessing the first page of the document
let page: PdfPage = document.getpage(0);
// Create a ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Initialize an array of strings
let products: string[] = ['Excel', 'Power Point', 'Word', 'Windows', 'MAUI'];
// Add the items to list item collection by passing the array of products
let itemCollection: PdfListItemCollection = new PdfListItemCollection(products);
// Retrieve a specific item from the list collection at a particular index
let item: PdflistItem = list.itemCollection.itemAt(1);
// Draw the list items on the page at specified coordinates and dimensions
list.draw(page, {x: 10, y: 50, width: 500, height: 700});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
index number The zero-based index of the item to retrieve.

Returns PdfListItem

clear

Clear the list item collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(readFromResources('CircleAnnotation-Acrobat.pdf'));
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Initialize an array of strings
let products: string[] = [
  'PDF is a file format designed to present documents consistently across devices and platforms.',
  'Excel is a widely used spreadsheet application developed by Microsoft.',
  'PDF stands for Portable Document Format.',
  'PowerPoint is a presentation program developed by Microsoft for creating slideshows.',
  'PowerPoint is widely used in business settings for creating presentations.'
];
// Add the items to list item collection by passing the array of products
let item: PdfListItemCollection = new PdfListItemCollection(products);
// Draw the initial list on the page at specified coordinates and dimensions
list.draw(page, {x: 10, y: 40, width: 300, height: 500});
// Clear the list item collection
list.items.clear();
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Returns void

indexOf

Finds the index of a PdfListItem in the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(readFromResources('CircleAnnotation-Acrobat.pdf'));
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Initialize an array of strings
let products: string[] = [
  'PDF is a file format designed to present documents consistently across devices and platforms.',
  'Excel is a widely used spreadsheet application developed by Microsoft.',
  'PDF stands for Portable Document Format.',
  'PowerPoint is a presentation program developed by Microsoft for creating slideshows.',
  'PowerPoint is widely used in business settings for creating presentations.'
];
// Add the items to list item collection by passing the array of products
list.items = new PdfListItemCollection(products);
// Retrieve the first item from the collection
let item: PdfListItem = item._listItems[0];
// Find the index of the first item in the collection
let index: number = list.items.indexOf(item);
// Draw the list on the page at specified bounds
list.draw(page, {x: 10, y: 40, width: 300, height: 500});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
item PdfListItem The list item to find in the collection.

Returns number

insert

Inserts a PdfListItem into the collection at the specified index.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(readFromResources('CircleAnnotation-Acrobat.pdf'));
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Initialize an array of strings
let products: string[] = [
  'PDF is a file format designed to present documents consistently across devices and platforms.',
  'Excel is a widely used spreadsheet application developed by Microsoft.',
  'PDF stands for Portable Document Format.',
  'PowerPoint is a presentation program developed by Microsoft for creating slideshows.',
  'PowerPoint is widely used in business settings for creating presentations.'
];
// Add the items to list item collection by passing the array of products
list.items = new PdfListItemCollection(products);
// Create a new PdfListItem instance with some text
let item: PdfListItem = new PdfListItem('text');
// Insert the new item into the list at index 1 with an indent of 40
list.items.insert(1, item, 40);
// Draw the updated list on the page at specified coordinates and dimensions
list.draw(page, {x: 10, y: 40, width: 300, height: 500});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
index number The zero-based index at which the item should be inserted.
item PdfListItem The list item to be inserted into the collection.
itemIndent number The indent of the list item.

Returns void

remove

Removes a PdfListItem from the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(readFromResources('CircleAnnotation-Acrobat.pdf'));
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Initialize an array of strings
let products: string[] = [
  'PDF is a file format designed to present documents consistently across devices and platforms.',
  'Excel is a widely used spreadsheet application developed by Microsoft.',
  'PDF stands for Portable Document Format.',
  'PowerPoint is a presentation program developed by Microsoft for creating slideshows.',
  'PowerPoint is widely used in business settings for creating presentations.'
];
// Add the items to list item collection by passing the array of products
let item: PdfListItemCollection = new PdfListItemCollection(products);
// Remove a specific item from the collection
let itemToRemove: PdfListItem = list.items.at(0);
list.items.remove(itemToRemove);
// Draw the list on the page at specified coordinates and dimensions
list.draw(page, {x: 10, y: 40, width: 300, height: 500});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
item PdfListItem The list item to be removed from the collection.

Returns void

removeAt

Removes a PdfListItem at the specified index from the collection.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(readFromResources('CircleAnnotation-Acrobat.pdf'));
// Access the first page of the document
let page: PdfPage = document.getPage(0);
// Create a ordered list
let list: PdfOrderedList = new PdfOrderedList();
// Initialize an array of strings
let products: string[] = [
  'PDF is a file format designed to present documents consistently across devices and platforms.',
  'Excel is a widely used spreadsheet application developed by Microsoft.',
  'PDF stands for Portable Document Format.',
  'PowerPoint is a presentation program developed by Microsoft for creating slideshows.',
  'PowerPoint is widely used in business settings for creating presentations.'
];
// Add the items to list item collection by passing the array of products
let item: PdfListItemCollection = new PdfListItemCollection(products);
// Remove a specific item from the collection by its index
list.items.removeAt(1);
// Draw the modified list on the page at specified bounds
list.draw(page, {x: 10, y: 40, width: 300, height: 500});
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
index number The zero-based index of the item to remove.

Returns void