Nutrient Python SDK
Need pricing or implementation help? Talk to Sales.
PDF EDITING IN PYTHON
from nutrient_sdk import Documentfrom nutrient_sdk import PdfEditorfrom nutrient_sdk import PdfExporterfrom nutrient_sdk import NutrientException
def main(): try: with Document.open("input.docx") as document: editor = PdfEditor.edit(document)
with Document.open("input.pdf") as document2: editor.append_document(document2)
editor.save() editor.close()
document.export("merged.pdf", PdfExporter()) print("Successfully merged documents") except NutrientException as e: print(f"Error: {e}")
if __name__ == "__main__": main()from nutrient_sdk import Documentfrom nutrient_sdk import PdfEditorfrom nutrient_sdk import NutrientException
def main(): try: with Document.open("input.pdf") as document: editor = PdfEditor.edit(document) pages = editor.get_page_collection()
# Remove pages you don't need pages.remove_at(pages.get_count() - 1) print("Removed last page")
editor.save_as("output.pdf") editor.close() except NutrientException as e: print(f"Error: {e}")
if __name__ == "__main__": main()from nutrient_sdk import Documentfrom nutrient_sdk import PdfEditorfrom nutrient_sdk import NutrientException
def main(): try: with Document.open("input.pdf") as document: editor = PdfEditor.edit(document) pages = editor.get_page_collection()
# Swap two pages pages.swap(0, 1)
# Move a page to a new position pages.move_to(0, 2)
editor.save_as("reordered.pdf") editor.close() except NutrientException as e: print(f"Error: {e}")
if __name__ == "__main__": main()USE CASES
Reports, invoices, and scanned pages arrive separately. Merge PDF files into a single document in a Django view, FastAPI endpoint, or background task.
Extract specific pages or remove sections from large documents. Split a PDF into smaller files for targeted delivery or archiving.
The SDK handles format conversion automatically — merge a Word document with a PDF and export the result as a single PDF.
Swap, move, and reorder pages programmatically. Build page-level editing into document management systems without manual PDF manipulation.
Combine PDF files and other documents into a single PDF in Python. The SDK handles document assembly and format conversion.
Split a PDF by removing pages or keeping only the pages you need. Use the page collection API to control document structure.
Swap, move, insert, and add pages to PDFs, with full programmatic control over page order and document structure.
ADVANCED CAPABILITIES
The SDK handles more than one-off edits. Build PDF manipulation into automated workflows and deploy anywhere Python runs.
Combine PDFs with Word documents — the SDK handles format conversion automatically when you append documents.
Iterate through pages in a loop to process, split, or reorganize multiple documents in a single script.
No GUI dependencies — merge, split, and edit PDFs in background jobs, cron tasks, or API handlers.
Deploy anywhere Python runs — the SDK has no platform-specific system dependencies.
Open the base document with Document.open(), create a PdfEditor, and then call editor.append_document() with each additional document. Save and export the result as a single PDF. The SDK handles page structures and document internals automatically. See the merge PDFs guide for a complete working example.
The SDK handles format conversion automatically. You can open a Word document as the base, append a PDF to it, and export the merged result as a single PDF. Use Document.open() for each file — the SDK manages format differences internally.
Open the PDF, create a PdfEditor, and use the page collection API to remove pages you don’t need with pages.remove_at(index). Then save the result as a new file. To extract specific pages, iterate through the collection and keep only the pages you want.
Install the Nutrient Python SDK and use PdfEditor with append_document() to combine files. The SDK is a standalone Python library — no external tools, system dependencies, or command-line utilities are required.
Yes. The page collection API provides swap(index1, index2) to exchange two pages and move_to(from, to) to relocate a page. You can also insert blank pages at specific positions with custom dimensions or predefined sizes like A4.
Use Document.open() to load the PDF and PdfEditor.edit() to create an editor. From there, you can merge documents, split pages, reorder content, and manage document structure. All changes are saved with editor.save_as().
Yes. Open the first file as the base document, and then call editor.append_document() for each additional file. The SDK appends all pages from each document in order. Export the final result with document.export() using PdfExporter.
Wrap your code in a try-except block and catch NutrientException for SDK-specific errors. Use the context manager syntax (with Document.open(...) as document:) to ensure automatic resource cleanup even when errors occur.
FREE TRIAL
Start merging, splitting, and editing PDFs in Python in minutes — no payment information required.