A “Hello, World!” example is often the first step when exploring GroupDocs.Annotation for Python via .NET. It serves as a simple test to confirm that your development environment is correctly set up and that the library is functioning as expected.
Overview
GroupDocs.Annotation for Python via .NET lets you add annotations, markup, and review comments to a wide range of document and image formats. A wide range of supported formats makes it versatile for different use cases.
How to annotate a document
The following steps demonstrate how to add an annotation to a document using GroupDocs.Annotation for Python via .NET:
Import the groupdocs.annotation classes you need.
Create an annotation and configure it (here, an area annotation with a yellow fill).
Open the document with an Annotator, pointing it at the sample file.
Add the annotation.
Save the result.
Complete example
The example below adds a yellow area (rectangle) annotation to the first page of a PDF and saves the annotated document:
fromgroupdocs.annotationimportAnnotatorfromgroupdocs.annotation.modelsimportRectanglefromgroupdocs.annotation.models.annotation_modelsimportAreaAnnotationfromgroupdocs.pydrawingimportColordefhello_world():# Describe a yellow area (rectangle) annotation on the first pagearea=AreaAnnotation()area.box=Rectangle(100,100,100,100)# x, y, width, heightarea.background_color=Color.yellow.to_argb()# packed ARGB int, not a Color objectarea.page_number=0# page numbers are 0-basedarea.message="Welcome to GroupDocs.Annotation!"# Open the document, add the annotation, and save the resultwithAnnotator("./sample.pdf")asannotator:annotator.add(area)annotator.save("./output.pdf")print("Annotation added successfully. Output saved to ./output.pdf.")if__name__=="__main__":hello_world()
sample.pdf is the sample file used in this example. Click here to download it.
This example writes the annotated document to output.pdf. Colors are passed as packed ARGB integers (for example Color.yellow.to_argb()), not as Color objects, and page numbers are 0-based, so page_number = 0 targets the first page. To annotate a different format, simply open a file with another extension — the same code works across every supported format.
Additional resources
This demo references the GroupDocs.Annotation for Python via .NET code samples.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.