Text Markup Annotation Classes Highlight, Underline, Strikeout and Jagged/Squiggly Underline

Table of Contents

  1. Introduction
  2. Methods
  3. Example

Introduction

Text markup annotations shall appear as highlights, underlines, strikeouts, or jagged (“squiggly”) underlines in the text of a document. They are represented in SetaPDF by following classes:

All of them are both a text markup and markup annotation

Methods

The classes implements getter and setter methods to access the individual annotation data:

getQuadPoints()

Get the quad points.

setQuadPoints()

Set the quad points.

Example

PHP
<?php

use setasign\SetaPDF2\Core\Document;
use setasign\SetaPDF2\Core\PageFormats;
use setasign\SetaPDF2\Core\Writer\HttpWriter;

require_once('library/SetaPDF/Autoload.php');

$writer = new HttpWriter('text-markup-annotation.pdf', true);
$document = new Document($writer);

// let's create a page
$pages = $document->getCatalog()->getPages();
$page = $pages->create(PageFormats::A4);

$annotations = $page->getAnnotations();

// create a highlight annotation
$annotation = new Document\Page\Annotation\HighlightAnnotation([50, 680, 70, 700]);
$annotation->setContents("A simple highlight annotation.");
$annotation->setTextLabel("John Dow"); // Used as Author in a Reader application
$annotation->setColor([1, 0, 0]);
$annotation->setSubject('A sticky note to a highlight annotation');
$annotations->add($annotation);

// create the popup
$popup = $annotation->createPopup();
$annotations->add($popup);
// assign the popup to the text annotation
$annotation->setPopup($popup);

$document->save()->finish();