Perform the requested operation:
Merge PDFs: Open each source file and append pages to a new PDF. Preserve bookmarks from /Root/Outlines if present. Write pages in explicit order. Check page sizes for consistency across merged documents.
Split by page range: Extract pages using zero-based indexing. Validate each page number is < len(pdf.pages). Create separate PDFs for each range with descriptive names like document_pages_1-10.pdf.
Rotate pages: Use page.rotate(90|180|270) on specific pages or all pages. Apply rotation before any other operations to avoid coordinate issues.
Add watermark: Create watermark PDF or use existing. Overlay on each page with page.merge_page(watermark_page) (PyPDF2) or pikepdf stamping. Set watermark position (center/top-left) and opacity. Place on top layer if PDF has both text and image layers.
Fill form fields: Get fields with reader.get_fields() or iterate /Annots. Map data keys to field names exactly. Write values, then optionally flatten: pdf.save('output.pdf', linearize=True). Verify field values before flattening.
Edit metadata: Update /Title, /Author, /Subject, /Keywords, /Creator, /CreationDate, /ModDate in the document info dictionary.
Redact content: Remove content from the page stream (pikepdf), not just overlay. For page removal, exclude the page when saving. Verify redacted content cannot be extracted as text.
Rearrange pages: Build new page list in desired order: new_pdf.pages.extend([pdf.pages[i] for i in new_order]).