J-F-Liu / lopdf

A Rust library for PDF document manipulation.
MIT License
1.67k stars 176 forks source link

Use IndexMap isntead of BTreeMap in TOC #267

Closed srv1n closed 9 months ago

srv1n commented 9 months ago

Replace the use of BTreeMap with IndexMap in TOC.

By default BTreemap is sorted ( in this case by title), so by default get_toc() returns the table of contents sorted alphabetically instead of the order they occur in the document.

For most parsing use cases the order of TOC matters.

Changes are minimal and just use IndexMap instead of BTreeMap.