createContentPositionTimeline

abstract fun createContentPositionTimeline(readerDocuments: List<ReaderDocument>, onSuccess: (ContentPositionTimeline) -> Unit, onError: (ColibrioException) -> Unit, progressCallback: (Double) -> Unit = {})

Creates a new ContentPositionTimeline using the specified list of ReaderDocuments. A ContentPositionTimeline is used for describing positions in ReaderPublication content as integers. The timeline starts at position 0 and its length can be retrieved using ContentPositionTimeline.length.

Choosing unit of measure

The ContentPositionTimeline can be configured with different unit of measures. At this moment, CHARACTERS are not available as a unit of measure for PDFs. By default, PAGES will be used as unit of measure.

PAGES

The timeline is created by counting all pages in the provided list of ReaderDocuments. Each position in the timeline points to the start of a page.

DOCUMENTS

The timeline is created by counting all provided ReaderDocuments.

Specifying the list of ReaderDocuments

The passed list of ReaderDocuments is validated according to the following rules:

  • The list must not be empty

  • All ReaderDocuments must belong to this publication.

  • All ReaderDocuments must be ordered as in the publication spine.

If the passed list of readerDocuments fails validation, the returned Promise will be rejected with an error.

Some examples:

const spine = readerPublication.getSpine();
readerPublication.createContentPositionTimeline(spine); // OK!
readerPublication.createContentPositionTimeline(spine.slice(1, 4)) // OK!
readerPublication.createContentPositionTimeline(spine.filter(item => item.isReflowable()); // OK!
readerPublication.createContentPositionTimeline(spine.reverse()); // ERROR!

Parameters

readerDocuments
  • The reader documents that should be part of the timeline.

onSuccess
  • Called with the new ContentPositionTimeline object if the operation is successful.

onError
  • Called if an error occurred while creating the timeline.

progressCallback
  • A function called several times indicating the create progress as a value between 0 and 1.


abstract suspend fun createContentPositionTimeline(readerDocuments: List<ReaderDocument>, progressCallback: (Double) -> Unit = {}): ColibrioResult<ContentPositionTimeline>

Creates a new ContentPositionTimeline using the specified list of ReaderDocuments. A ContentPositionTimeline is used for describing positions in ReaderPublication content as integers. The timeline starts at position 0 and its length can be retrieved using ContentPositionTimeline.length.

Choosing unit of measure

The ContentPositionTimeline can be configured with different unit of measures. At this moment, CHARACTERS are not available as a unit of measure for PDFs. By default, PAGES will be used as unit of measure.

PAGES

The timeline is created by counting all pages in the provided list of ReaderDocuments. Each position in the timeline points to the start of a page.

DOCUMENTS

The timeline is created by counting all provided ReaderDocuments.

Specifying the list of ReaderDocuments

The passed list of ReaderDocuments is validated according to the following rules:

  • The list must not be empty

  • All ReaderDocuments must belong to this publication.

  • All ReaderDocuments must be ordered as in the publication spine.

If the passed list of readerDocuments fails validation, the returned Promise will be rejected with an error.

Some examples:

const spine = readerPublication.getSpine();
readerPublication.createContentPositionTimeline(spine); // OK!
readerPublication.createContentPositionTimeline(spine.slice(1, 4)) // OK!
readerPublication.createContentPositionTimeline(spine.filter(item => item.isReflowable()); // OK!
readerPublication.createContentPositionTimeline(spine.reverse()); // ERROR!

Return

Either ColibrioResult.Success with the new ContentPositionTimeline object if the operation is successful, or ColibrioResult.Error if an error occurred while creating the timeline.

Parameters

readerDocuments
  • The reader documents that should be part of the timeline.

progressCallback
  • A function called several times indicating the create progress as a value between 0 and 1.