Class PdfAnnotationCollection
Represents the collection of PdfAnnotation objects.
Implements
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfAnnotationCollection : PdfCollection, IEnumerable, IPdfWrapper
Remarks
This PdfAnnotationCollection class is used to get the collection of annotations in a page. Please refer the UG docuemntation link for PdfAnnotationCollection in https://help.syncfusion.com/file-formats/pdf/working-with-annotations#sound-annotation
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
PdfAnnotation annotation = annotationCollection[0] as PdfAnnotation;
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
Dim annotation As PdfAnnotation = TryCast(annotationCollection(0), PdfAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
Constructors
PdfAnnotationCollection()
Initializes a new instance of the PdfAnnotationCollection class.
Declaration
public PdfAnnotationCollection()
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = new PdfAnnotationCollection();
annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
PdfAnnotation annotation = annotationCollection[0] as PdfAnnotation;
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection()
annotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
Dim annotation As PdfAnnotation = TryCast(annotationCollection(0), PdfAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
PdfAnnotationCollection(PdfPage)
Initializes a new instance of the PdfAnnotationCollection class with the specified page.
Declaration
public PdfAnnotationCollection(PdfPage page)
Parameters
Type | Name | Description |
---|---|---|
PdfPage | page | Page which collection is created for. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = new PdfAnnotationCollection(page);
annotationCollection.Add(soundAnnotation);
PdfAnnotation annotation = annotationCollection[0] as PdfAnnotation;
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection(page)
annotationCollection.Add(soundAnnotation)
Dim annotation As PdfAnnotation = TryCast(annotationCollection(0), PdfAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
Properties
Item[Int32]
Gets the PdfAnnotation object at the specified index. Read-Only.
Declaration
public virtual PdfAnnotation this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index value of the annotation in the collection. |
Property Value
Type | Description |
---|---|
PdfAnnotation | The PdfAnnotation specifies the attachment at the specified position. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
PdfAnnotation annotation = annotationCollection[0] as PdfAnnotation;
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
Dim annotation As PdfAnnotation = TryCast(annotationCollection(0), PdfAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
Methods
Add(PdfAnnotation)
Adds a new annotation to the collection.
Declaration
public virtual int Add(PdfAnnotation annotation)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annotation | The new annotation to be added to the collection. |
Returns
Type | Description |
---|---|
System.Int32 | The position of the annotation in the collection. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle.
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
Clear()
Removes all the annotations from the collection.
Declaration
public void Clear()
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
//Clear the annotation collection.
annotationCollection.Clear();
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
'Clear the annotation collection.
annotationCollection.Clear()
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
Contains(PdfAnnotation)
Determines whether a specified annotation is in the annotation collection.
Declaration
public bool Contains(PdfAnnotation annotation)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annotation | The annotation to search for. |
Returns
Type | Description |
---|---|
System.Boolean | True, if annotation is contained in collection. Otherwise - false. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
//Add the sound annotation to annotation collection.
annotationCollection.Add(soundAnnotation);
bool exist = annotationCollection.Contains(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
'Add the sound annotation to annotation collection.
annotationCollection.Add(soundAnnotation)
Dim exist As Boolean = annotationCollection.Contains(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
DoAdd(PdfAnnotation)
Adds a Annotation to collection.
Declaration
protected virtual int DoAdd(PdfAnnotation annot)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annot |
Returns
Type |
---|
System.Int32 |
DoClear()
Clears the collection.
Declaration
protected virtual void DoClear()
DoInsert(Int32, PdfAnnotation)
Inserts a annotation into collection.
Declaration
protected virtual void DoInsert(int index, PdfAnnotation annot)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
PdfAnnotation | annot |
DoRemove(PdfAnnotation)
Removes the annotation.
Declaration
protected virtual void DoRemove(PdfAnnotation annot)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annot |
DoRemoveAt(Int32)
Removes the annotation at the specified position.
Declaration
protected virtual void DoRemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index. |
IndexOf(PdfAnnotation)
Searches the index of the specified annotation from the collection.
Declaration
public int IndexOf(PdfAnnotation annotation)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annotation | The annotation to be searched. |
Returns
Type | Description |
---|---|
System.Int32 | Index of the element in the collection, if exists, or -1 if the element does not exist in the collection. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
//Get the index
int index = annotationCollection.IndexOf(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
'Get the index
Dim index As Integer = annotationCollection.IndexOf(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
Insert(Int32, PdfAnnotation)
Inserts an annotation to the collection at the specified index.
Declaration
public void Insert(int index, PdfAnnotation annotation)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index where to insert the element. |
PdfAnnotation | annotation | The annotation to be inserted in the collection. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Insert(0, soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Insert(0, soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
Remove(PdfAnnotation)
Removes the specified annotation from the collection.
Declaration
public void Remove(PdfAnnotation annot)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annot | The annotation to be removed. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
//Remove a sound annotation.
annotationCollection.Remove(soundAnnotation);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
'Remove a sound annotation.
annotationCollection.Remove(soundAnnotation)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document
document.Close(True)
See Also
RemoveAt(Int32)
Removes the annotation at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the element to be removed. |
Examples
//Create a new PDF Document.
PdfDocument document = new PdfDocument();
//Create a new page.
PdfPage page = document.Pages.Add();
//Create a new rectangle.
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create a new sound annotation.
PdfSoundAnnotation soundAnnotation = new PdfSoundAnnotation(rectangle, @"Input.wav");
//Add this annotation to a new page.
PdfAnnotationCollection annotationCollection = page.Annotations;
annotationCollection.Add(soundAnnotation);
//Removes a sound annotation at specified index.
annotationCollection.RemoveAt(0);
//Save the document to disk.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
'Create a new PDF Document.
Dim document As New PdfDocument()
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle.
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new sound annotation.
Dim soundAnnotation As New PdfSoundAnnotation(rectangle, "Input.wav")
'Add this annotation to a new page.
Dim annotationCollection As PdfAnnotationCollection = page.Annotations
annotationCollection.Add(soundAnnotation)
'Removes a sound annotation at specified index.
annotationCollection.RemoveAt(0)
'Save the document to disk.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
See Also
SetPrint(PdfAnnotation)
prints the specified annotation.
Declaration
public void SetPrint(PdfAnnotation annot)
Parameters
Type | Name | Description |
---|---|---|
PdfAnnotation | annot | The annotation to be printed. |