fetchContentLocationFromHref

abstract fun fetchContentLocationFromHref(href: String, baseUrl: String? = null, onSuccess: (ContentLocation) -> Unit, onError: (ColibrioException) -> Unit)

Fetches a ContentLocation for hrefs like chapter02.xhtml#title-4.

If href is a relative URL, you can specify a baseUrl to from where href is relative to. If you don't specify a baseUrl it will default to the root of the EPUB.

For example: To resolve a relative href link found in a ReaderDocument, you should pass the URL of that ReaderDocument as baseUrl:

readerPublication.fetchContentLocationFromHref(href, readerDocument.sourceContentDocument.contentUrl, {...}, {...})

onError is called if:

  • href does not resolve to a ReaderDocument in this publication.

  • a "#hash" is specified in href and does not match any element id in the document.


abstract suspend fun fetchContentLocationFromHref(href: String, baseUrl: String? = null): ColibrioResult<ContentLocation>

Fetches a ContentLocation for hrefs like chapter02.xhtml#title-4.

If href is a relative URL, you can specify a baseUrl to from where href is relative to. If you don't specify a baseUrl it will default to the root of the EPUB.

For example: To resolve a relative href link found in a ReaderDocument, you should pass the URL of that ReaderDocument as baseUrl:

readerPublication.fetchContentLocationFromHref(href, readerDocument.sourceContentDocument.contentUrl)

The returned ColibrioResult is an error if:

  • href does not resolve to a ReaderDocument in this publication.

  • a "#hash" is specified in href and does not match any element id in the document.