The function seems to always throw the exception "Cycle detected in outlines" for any PDF that has a table of contents. Among failing PDFs also is the Adobe PDF specification 2008. In PyMuPDF, we can only work with the variant pdf_rearrange_page2(doc, list, 0) which interfaces with the original.
Fixed with: commit f84bb9fbe8abea011d500d28d90e3c31c576a209 Author: Robin Watts <Robin.Watts@artifex.com> Date: Tue May 13 19:47:55 2025 +0100 Bug 708541: Fix cycle detection in pdf_rearrange_pages. We were marking/checking an object for cycles in strip_outline, but we immediately call strip_outlines with it, which checks itself! Only check in strip_outlines.
Thanks for such a fast fix!