Adding sticky note annotations to a PDF document
Use sticky note annotations to add comment markers to PDF files.
Common use cases include:
- Review workflows
- Team feedback and commenting systems
- Quality assurance notes
- Collaborative document editing
Sticky notes appear as icons on the page. Users can open each icon to read the full comment text.
Download sampleHow Nutrient helps
Nutrient Python SDK handles sticky note annotation structures and appearance generation.
The SDK handles:
- Text annotation dictionaries and popup configuration
- Sticky note icon styles and appearance states
- Author metadata and timestamp formatting
- Popup positioning and content rendering
Complete implementation
This example adds sticky note annotations with different colors:
from nutrient_sdk import Documentfrom nutrient_sdk import PdfEditorfrom nutrient_sdk import Colorfrom nutrient_sdk import NutrientExceptionWorking with sticky note annotations
Open the document in a context manager(opens in a new tab) so resources are cleaned up after processing.
Then:
- Create a PDF editor.
- Get the page collection.
- Add a letter-size page (
612 × 792) if the document is empty. - Get 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
Add a note with add_sticky_note(x, y, author, subject, contents).
In this sample:
- The position is
(100, 700). - The metadata includes author and subject.
- The contents store the full comment text.
- The default note color is yellow.
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
Add multiple notes and use color to indicate status.
This sample:
- Adds an urgent note at
(100, 600)and sets it to red - Adds an approval note at
(100, 500)and sets it to green - Uses vertical spacing to prevent icon overlap
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
Save the output PDF and close the editor.
The except block catches NutrientException if processing fails:
editor.save_as("output.pdf") editor.close() except NutrientException as e: print(f"Error: {e}")
if __name__ == "__main__": main()Conclusion
Use this workflow to add sticky note annotations:
- 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.
For related annotation workflows, refer to the Python SDK annotation guides.