Adding sticky note annotations to a PDF document
Adding sticky note annotations to PDFs programmatically enables teams to automate document review workflows, build commenting systems, and implement collaborative feedback pipelines. Whether you’re creating automated review comments, building document feedback tools, implementing quality assurance workflows, creating annotation systems for technical reviews, or building collaborative editing platforms, sticky note annotations provide icon-based comment markers that display text content when clicked. Unlike free text annotations that render text directly on the page, sticky note annotations appear as compact icons that expand to show full comment content, conserving page space while enabling detailed feedback.
How Nutrient helps you achieve this
Nutrient Python SDK handles PDF sticky note annotation structures and appearance generation. With the SDK, you don’t need to worry about:
- Parsing text annotation dictionaries and popup window configurations
- Managing sticky note icon styles and appearance states
- Handling annotation author metadata and timestamp formatting
- Complex annotation popup positioning and content rendering
Instead, Nutrient provides an API that handles all the complexity behind the scenes, letting you focus on your business logic.
Complete implementation
Below is a complete working example that demonstrates adding sticky note annotations with various colors to a PDF. The following lines set up the Python application. The import statements bring in all necessary classes from the Nutrient SDK:
from nutrient_sdk import Documentfrom nutrient_sdk import PdfEditorfrom nutrient_sdk import Colorfrom nutrient_sdk import NutrientExceptionWorking with sticky note annotations
The main() function defines the entry point that will contain the sticky note annotation creation logic. The Document.open() call opens the PDF document. The context manager(opens in a new tab) syntax ensures the document is automatically closed when you’re done, preventing resource leaks. The following code creates a PDF editor, accesses the page collection, ensures at least one page exists by adding a letter-size page (612×792 points) if the document is empty, and retrieves the annotation collection from the first page:
def main(): try: with Document.open("input.pdf") as document: editor = PdfEditor.edit(document) pages = editor.get_page_collection()
if pages.get_count() == 0: pages.add(612.0, 792.0)
page = pages.get_first() annotations = page.get_annotation_collection()Adding a sticky note annotation
The following code adds a sticky note annotation at coordinates (100, 700) with the add_sticky_note() method. The first two parameters define the icon position on the page, followed by author name, subject line, and the full comment contents. Sticky note annotations are created with a default yellow color and appear as compact icons that expand into popup windows when clicked, displaying the author, subject, and full contents text. This pattern is commonly used for document review comments, feedback collection, and collaborative editing workflows:
sticky_note = annotations.add_sticky_note( 100.0, 700.0, "Review Author", "Review Comment", "This section needs clarification. Please add more details about the implementation." )Adding multiple sticky notes
The following code demonstrates creating multiple sticky notes with color categorization for different comment types. The first sticky note is positioned at coordinates (100, 600), 100 points below the previous annotation to prevent icon overlap. After creation, the color property is assigned a red color using ARGB values (255, 255, 0, 0), creating a visual indicator for urgent issues that must be addressed before release. The second sticky note is positioned at (100, 500), maintaining the 100-point vertical spacing pattern. This approval note is customized with a green color using ARGB values (255, 0, 255, 0), providing visual distinction for approved sections. This color categorization approach enables teams to implement review workflows where red indicates urgent issues, green indicates approvals, and yellow (the default) represents standard comments:
urgent_note = annotations.add_sticky_note( 100.0, 600.0, "Reviewer", "Urgent", "This issue must be addressed before release." ) # Optionally customize the color urgent_note.color = Color.from_argb(255, 255, 0, 0)
approval_note = annotations.add_sticky_note( 100.0, 500.0, "Approver", "Approved", "This section looks good." ) # Optionally customize the color approval_note.color = Color.from_argb(255, 0, 255, 0)Saving the document
The final code block saves the document with all sticky note annotations and closes the editor. The try-except block handles potential errors using NutrientException:
editor.save_as("output.pdf") editor.close() except NutrientException as e: print(f"Error: {e}")
if __name__ == "__main__": main()Conclusion
The sticky note annotation workflow consists of several key operations:
- Open the document using a context manager(opens in a new tab) for automatic resource cleanup.
- Create an editor and access the page collection.
- Ensure at least one page exists by adding a letter-size page if needed.
- Retrieve the annotation collection from the target page.
- Add sticky note annotations with coordinates, author, subject, and contents using
add_sticky_note(). - Sticky notes appear as compact icons that expand into popup windows when clicked.
- Customize colors using the
colorproperty with ARGB values for color categorization. - Use 100-point vertical spacing between annotations to prevent icon overlap.
- Implement color categorization workflows (red for urgent, green for approved, yellow for standard).
- Save and close the editor.
Nutrient handles sticky note annotation dictionary structures, popup window configurations, author metadata, timestamp formatting, and appearance generation so you don’t need to understand PDF text annotation specifications or manage popup positioning manually. The sticky note annotation system provides icon-based comment markers for document review workflows, commenting systems, collaborative feedback pipelines, and quality assurance workflows.