remove method
Remove the specified bookmark from the document.
//Load the PDF document.
PdfDocument document = PdfDocument(inputBytes: inputBytes);
//Get all the bookmarks.
PdfBookmarkBase bookmarks = document.bookmarks;
//Remove specified bookmark.
bookmarks.remove('bookmark');
//Save the document.
List<int> bytes = await document.save();
//Dispose the document.
document.dispose();
Implementation
void remove(String title) {
int index = -1;
if (_bookmark == null || _bookmark!.length < _list.length) {
_bookmark = <PdfBookmark>[];
for (int n = 0; n < _list.length; n++) {
if (_list[n] is PdfBookmark) {
_bookmark!.add(_list[n] as PdfBookmark);
}
}
}
for (int c = 0; c < _bookmark!.length; c++) {
final PdfBookmark pdfbookmark = _bookmark![c];
if (pdfbookmark.title == title) {
index = c;
break;
}
}
removeAt(index);
}