namespace UglyToad.PdfPig.Annotations
{
using System;
using System.Collections.Generic;
using Core;
using Tokens;
using Util.JetBrains.Annotations;
///
/// An annotation on a page in a PDF document.
///
public class Annotation
{
private readonly StreamToken normalAppearanceStream;
private readonly StreamToken rollOverAppearanceStream;
private readonly StreamToken downAppearanceStream;
///
/// The underlying PDF dictionary which this annotation was created from.
///
[NotNull]
public DictionaryToken AnnotationDictionary { get; }
///
/// The type of this annotation.
///
public AnnotationType Type { get; }
///
/// The rectangle in user space units specifying the location to place this annotation on the page.
///
public PdfRectangle Rectangle { get; }
///
/// The annotation text, or if the annotation does not display text, a description of the annotation's contents. Optional.
///
[CanBeNull]
public string Content { get; }
///
/// The name of this annotation which should be unique per page. Optional.
///
[CanBeNull]
public string Name { get; }
///
/// The date and time the annotation was last modified, can be in any format. Optional.
///
[CanBeNull]
public DateTimeOffset ModifiedDate { get; }
///
/// Flags defining the appearance and behaviour of this annotation.
///
public AnnotationFlags Flags { get; }
///
/// Defines the annotation's border.
///
public AnnotationBorder Border { get; }
///
/// Rectangles defined using QuadPoints, for these are the regions used to activate the link,
/// for text markup annotations these are the text regions to apply the markup to.
/// See for more information regarding the order of the points.
///
public IReadOnlyList QuadPoints { get; }
///
/// Indicates if a roll over appearance is present for this annotation (shown when you hover over this annotation)
///
public bool HasRollOverAppearance => rollOverAppearanceStream != null;
///
/// Indicates if a down appearance is present for this annotation (shown when you click on this annotation)
///
public bool HasDownAppearance => downAppearanceStream != null;
///
/// Create a new .
///
public Annotation(DictionaryToken annotationDictionary, AnnotationType type, PdfRectangle rectangle, string content, string name, DateTimeOffset modifiedDate,
AnnotationFlags flags, AnnotationBorder border, IReadOnlyList quadPoints,
StreamToken normalAppearanceStream, StreamToken rollOverAppearanceStream, StreamToken downAppearanceStream)
{
AnnotationDictionary = annotationDictionary ?? throw new ArgumentNullException(nameof(annotationDictionary));
Type = type;
Rectangle = rectangle;
Content = content;
Name = name;
ModifiedDate = modifiedDate;
Flags = flags;
Border = border;
QuadPoints = quadPoints ?? EmptyArray.Instance;
this.normalAppearanceStream = normalAppearanceStream;
this.rollOverAppearanceStream = rollOverAppearanceStream;
this.downAppearanceStream = downAppearanceStream;
}
///
public override string ToString()
{
return $"{Type} - {Content}";
}
}
}