> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/annotation/highlight-annotation.md).

# Add a highlight annotation to a PDF on Server/Desktop

Learn how to add a highlight annotation to a PDF Document page with this code sample. Easily add or edit various PDF annotations like hyperlink, stamp, text, and more. The Apryse Server SDK streamline

To add a highlight annotation to a PDF Document page.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Page page = doc.GetPage(1);

// Create a highlight
Highlight hl = Highlight.Create( doc, new Rect(100,490,150,515) );
hl.SetColor(new ColorPt(0,1,0), 3 );
hl.RefreshAppearance();
page.AnnotPushBack(hl);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFDoc doc(filename);
Page page = doc.GetPage(1);

// Create a highlight
Highlight hl = Highlight::Create( doc, Rect(100,490,150,515) );
hl.SetColor( ColorPt(0,1,0), 3 );
hl.RefreshAppearance();
page.AnnotPushBack( hl );
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
doc := NewPDFDoc(filename)
page := doc.GetPage(1)

// Create a highlight
hl := HighlightAnnotCreate( doc.GetSDFDoc(), NewRect(100.0, 490.0, 150.0, 515.0) )
hl.SetColor( NewColorPt(0.0,1.0,0.0), 3 )
hl.RefreshAppearance()
page.AnnotPushBack( hl )
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);
Page page = doc.getPage(1);

// Create a highlight
Highlight hl = Highlight.create(doc, new Rect(100, 490, 150, 515));
hl.setColor(new ColorPt(0, 1, 0), 3);
hl.refreshAppearance();
page.annotPushBack(hl);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
async function main() {
  const doc = await PDFNet.PDFDoc.createFromURL(filename);
  const page = await doc.getPage(1);

  // Create a highlight
  const hl = await PDFNet.HighlightAnnot.create(
    doc,
    new PDFNet.Rect(100, 490, 150, 515)
  );
  await hl.setColor(await PDFNet.ColorPt.init(0, 1, 0), 3);
  await hl.refreshAppearance();
  await page.annotPushBack(hl);
}
PDFNet.runWithCleanup(main);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val page = doc.getPage(1)

// Create a highlight
val hl = Highlight.create(doc, Rect(100.0, 490.0, 150.0, 515.0))
hl.setColor(ColorPt(0.0, 1.0, 0.0), 3)
hl.refreshAppearance()
page.annotPushBack(hl)
```

{% endcode %}
{% endtab %}

{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
PTPage *page = [doc GetPage:1];

// Create a highlight
PTHighlightAnnot *hl = [PTHighlightAnnot Create: [doc GetSDFDoc] pos: [[PTPDFRect alloc] initWithX1: 100 y1: 490 x2: 150 y2: 515]];
[hl SetColor: [[PTColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] numcomp: 3];
[hl RefreshAppearance];
[page AnnotPushBack: hl];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let doc: PTPDFDoc = PTPDFDoc(filepath: filename)
let page: PTPage = doc.getPage(1)

// Create a highlight
let hl: PTHighlightAnnot = PTHighlightAnnot.create(doc.getSDFDoc(), pos: PTPDFRect(x1: 100, y1: 490, x2: 150, y2: 515))
hl.setColor(PTColorPt(x: 0, y: 1, z: 0, w: 0), numcomp: 3)
hl.refreshAppearance()
page.annotPushBack(hl)
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$doc = new PDFDoc($filename);
$page = $doc->GetPage(1);

// Create a highlight
$hl = HighlightAnnot::Create( $doc->GetSDFDoc(), new Rect(100.0,490.0,150.0,515.0) );
$hl->SetColor( new ColorPt(0.0,1.0,0.0), 3 );
$hl->RefreshAppearance();
$page->AnnotPushBack( $hl );
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
doc = PDFDoc(filename)
page = doc.GetPage(1)

# Create a highlight
hl = HighlightAnnot.Create( doc.GetSDFDoc(), Rect(100,490,150,515) )
hl.SetColor( ColorPt(0,1,0), 3 )
hl.RefreshAppearance()
page.AnnotPushBack( hl )
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
doc = PDFDoc.new(filename)
page = doc.GetPage(1)

# Create a highlight
hl = HighlightAnnot.Create( doc.GetSDFDoc(), Rect.new(100,490,150,515) )
hl.SetColor( ColorPt.new(0,1,0), 3 )
hl.RefreshAppearance()
page.AnnotPushBack( hl )
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim doc As PDFDoc = New PDFDoc(filename)
Dim page As Page = doc.GetPage(1)

' Create a highlight
Dim hl As Highlight = Highlight.Create(doc, New Rect(100, 490, 150, 515))
hl.SetColor(New ColorPt(0, 1, 0), 3)
hl.RefreshAppearance()
page.AnnotPushBack(hl)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Add or edit PDF annotations sample](/core/get-started/samples/annotationtest.md) Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, highlight, squiggly, caret, and ink). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/annotation/highlight-annotation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
