# Implementing document anchoring/bookmarking in embedded Collabora Online

**URL:** <https://forum.collaboraonline.com/t/implementing-document-anchoring-bookmarking-in-embedded-collabora-online/3973>\
**Category:** Development\
**Created:** [August 29, 2025, 5:02am UTC](https://forum.collaboraonline.com/t/implementing-document-anchoring-bookmarking-in-embedded-collabora-online/3973 "2025-08-29T05:02:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinericksonn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/martinericksonn/32/1717_2.png) [@martinericksonn](https://forum.collaboraonline.com/u/martinericksonn)\
**Post date:** [August 29, 2025, 5:02am UTC](https://forum.collaboraonline.com/t/implementing-document-anchoring-bookmarking-in-embedded-collabora-online/3973/1 "2025-08-29T05:02:21Z")

</div>

Hi everyone, I’m working on a document bookmarking feature where users can save references to specific content in embedded Collabora Online documents. The feature needs to work with **PDF, DOCX, XLSX, and PPTX files** in **strict read-only mode**. I have text search and highlighting working, but the viewport doesn’t automatically scroll to show the highlighted content.

## Current working solution

Text search and highlighting works using postMessage

```javascript
function findAndHighlightText(searchText) {
    const iframe = document.getElementById('collabora-iframe');
    iframe.contentWindow.postMessage({
        MessageId: 'Action_Find',
        Values: {
            SearchItem: {
                SearchString: { type: 'string', value: searchText },
                Backward: { type: 'boolean', value: false },
                FindAll: { type: 'boolean', value: false }
            }
        }
    }, '*');
}

```

**Current behavior** : Text gets found and highlighted in yellow, but Collabora doesn’t scroll to show it

## The problem

I have the coordinates where the text was originally located:

```javascript
const originalCoordinates = { x: 1006, y: 1296 };

```

But I can’t get Collabora to scroll to those coordinates programmatically.

## What I’ve tried (all failed)

### PostMessage scroll commands - no API available

```javascript
// These MessageId types don't seem to exist
iframe.contentWindow.postMessage({
    MessageId: 'Action_ScrollTo', // Not valid
    Values: { x: 1006, y: 1296 }
}, '*');

iframe.contentWindow.postMessage({
    MessageId: 'UI_ScrollToPosition', // Not valid  
    Values: { x: 1006, y: 1296 }
}, '*');

```

### UNO commands - limited positioning support

```javascript
// These don't provide viewport control
iframe.contentWindow.postMessage({
    MessageId: 'uno:.uno:GoToPage',
    Values: { Page: 1 }
}, '*');

```

## Workarounds that partially help

### 1. Document reload with search parameters

```javascript
function reloadWithSearch(searchText) {
    const iframe = document.getElementById('collabora-iframe');
    const url = new URL(iframe.src);
    url.searchParams.set('search', searchText);
    url.searchParams.set('highlight', 'true');
    iframe.src = url.toString();
    
    // Follow up with search command after reload
    setTimeout(() => {
        findAndHighlightText(searchText);
    }, 3000);
}

```

This doesn’t actually work reliably - the reload approach was something I hoped would work but it doesn’t provide consistent viewport positioning. Collabora loads the document but doesn’t automatically scroll to highlighted search results.

### 2. Multiple search strategies

```javascript
function enhancedSearch(searchText) {
    // Try regular find
    findAndHighlightText(searchText);
    
    // Try find with replace dialog (sometimes scrolls better)
    setTimeout(() => {
        iframe.contentWindow.postMessage({
            MessageId: 'Action_FindReplace',
            Values: {
                SearchItem: {
                    SearchString: { type: 'string', value: searchText }
                }
            }
        }, '*');
    }, 500);
}

```

## Questions

1. **Is there a postMessage command for viewport scrolling** that I’m missing from the documentation?

2. **Are there URL parameters** that control initial scroll position when loading a document?

3. **Can I simulate keyboard shortcuts** like Ctrl+F to open Collabora’s native find dialog?

4. **Is this a known limitation** with any planned fixes or workarounds?

## Environment details

- Collabora CODE in Docker

- iframe embedding with postMessage API

- WOPI host for document serving

- **Strict read-only document mode** (no modifications allowed)

- **Target formats** : PDF, DOCX, XLSX, PPTX

Has anyone solved this viewport positioning challenge with embedded Collabora?

---

<div class="post-metadata">

**Author:** ![darshan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/darshan/32/2230_2.png) [@darshan](https://forum.collaboraonline.com/u/darshan)\
**Post date:** [September 3, 2025, 7:37am UTC](https://forum.collaboraonline.com/t/implementing-document-anchoring-bookmarking-in-embedded-collabora-online/3973/2 "2025-09-03T07:37:34Z")

</div>

Hi @martinericksonn

there’s no API today to scroll the viewport to a search hit or coordinates, and no announced fix/workaround beyond jumping to pages with `.uno:GoToPage`.

If you’d like this improved, you can contribute or file a feature request — Collabora Online is open source with a large, supportive community. Setup and contribution guide is here: [collaboraonline.github.io](https://collaboraonline.github.io/). We’d be extremely happy if you help bring this functionality in!
