Class PdfAnnotationCollection
- Namespace
- Syncfusion.Pdf.Interactive
- Assembly
- Syncfusion.Pdf.Portable.dll
Represents the collection of PdfAnnotation objects.
public class PdfAnnotationCollection : PdfCollection, IEnumerable
- Inheritance
-
PdfAnnotationCollection
- Implements
- Derived
- Inherited Members
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)
Remarks
This PdfAnnotationCollection class is used to get the collection of annotations in a page. Please refer the UG docuemntation link for PdfAnnotationCollection in
Constructors
PdfAnnotationCollection()
Initializes a new instance of the PdfAnnotationCollection class.
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.
public PdfAnnotationCollection(PdfPage page)
Parameters
page
PdfPagePage 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
this[int]
Gets the PdfAnnotation object at the specified index. Read-Only.
public virtual PdfAnnotation this[int index] { get; }
Parameters
index
intThe index value of the annotation in the collection.
Property Value
- 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.
public virtual int Add(PdfAnnotation annotation)
Parameters
annotation
PdfAnnotationThe new annotation to be added to the collection.
Returns
- int
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.
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.
public bool Contains(PdfAnnotation annotation)
Parameters
annotation
PdfAnnotationThe annotation to search for.
Returns
- bool
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.
protected virtual int DoAdd(PdfAnnotation annot)
Parameters
annot
PdfAnnotation
Returns
- See Also
DoClear()
Clears the collection.
protected virtual void DoClear()
- See Also
DoInsert(int, PdfAnnotation)
Inserts a annotation into collection.
protected virtual void DoInsert(int index, PdfAnnotation annot)
Parameters
index
intThe index.
annot
PdfAnnotation
- See Also
DoRemove(PdfAnnotation)
Removes the annotation.
protected virtual void DoRemove(PdfAnnotation annot)
Parameters
annot
PdfAnnotation
- See Also
DoRemoveAt(int)
Removes the annotation at the specified position.
protected virtual void DoRemoveAt(int index)
Parameters
index
intThe index.
- See Also
IndexOf(PdfAnnotation)
Searches the index of the specified annotation from the collection.
public int IndexOf(PdfAnnotation annotation)
Parameters
annotation
PdfAnnotationThe annotation to be searched.
Returns
- int
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(int, PdfAnnotation)
Inserts an annotation to the collection at the specified index.
public void Insert(int index, PdfAnnotation annotation)
Parameters
index
intThe index where to insert the element.
annotation
PdfAnnotationThe 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.
public void Remove(PdfAnnotation annot)
Parameters
annot
PdfAnnotationThe 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(int)
Removes the annotation at the specified index.
public void RemoveAt(int index)
Parameters
index
intThe 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.
public void SetPrint(PdfAnnotation annot)
Parameters
annot
PdfAnnotationThe annotation to be printed.
- See Also