rmapi-js
    Preparing search index...

    Class ClientDocumentContent

    a document's .content read through a Client, with its reference, to edit and push back

    It reads and edits as a DocumentContent does, and pushes, pulls, merges and gives its file back as a ClientMetadata does.

    Hierarchy (View Summary)

    Index
    • get cover(): number | "lastVisited" | undefined

      the page the thumbnail comes from, from zero, or "lastVisited"; or undefined for a number that names no page

      Returns number | "lastVisited" | undefined

    • get dummyDocument(): boolean | undefined

      the dummyDocument flag

      Returns boolean | undefined

    • get fontName(): string

      the font, empty for the device's own

      Returns string

    • get formatVersion(): number | undefined

      the format version of the file

      Returns number | undefined

    • get hasEdits(): boolean

      whether an edit changes the file from the version as read

      Returns boolean

    • get lastOpenedPage(): number | undefined

      the place in the page order of the page last open

      Returns number | undefined

    • get lineHeight(): number | undefined

      the line height, or undefined for the device's own

      Returns number | undefined

    • get margins(): number | undefined

      the margins, in pixels

      Returns number | undefined

    • get originalPageCount(): number | undefined

      the number of pages of the original pdf or epub

      Returns number | undefined

    • get pageCount(): number

      the number of pages the file says it has

      Returns number

    • get sizeInBytes(): string | undefined

      the size the file says the document has, as text

      Returns string | undefined

    • get textScale(): number

      the font size

      Returns number

    • get zoom(): Zoom | undefined

      how it is scaled to the screen, or undefined if the file does not say in a way the core reads, such as a mode it has no name for or a custom zoom missing a value

      Returns Zoom | undefined

    • whether it is an epub the tablet never laid out, which lists no page ids and has no pdf among bodies, so a reader gives it page ids as the reMarkable Mac app does

      Parameters

      Returns boolean

    • the pages list of older files, or undefined when absent or null

      The page edits, such as addPage, edit cPages when the document has it, and else this list, when it lists ids; a document with neither refuses them until setPages gives it ids.

      Returns string[] | undefined

    • remove a key of the file: a key the core reads clears its field, or sets it to what a file without the key reads it as

      Parameters

      • key: string

      Returns this

      Warning: as for setExtra, this can leave the file at odds with itself. Prefer the field's own setter.

      ValidationError if key names a field the file must have; the file is left as it was

    • set the page the thumbnail comes from

      Parameters

      • cover: number | "lastVisited"

      Returns this

      RangeError if cover is not "lastVisited" or an integer from 0 to 2^32 - 1

    • set a key of the file: a key the core reads sets its field, and any other is kept in extra

      Parameters

      • key: string
      • value: Json

      Returns this

      Warning: a key the core reads is written as given, past the rules its own setter keeps, so it can leave the file at odds with itself, such as a pageCount that does not count the pages listed. Prefer the field's own setter, such as setPages for the page keys.

      ValidationError if value is not a value of the field key names; the file is left as it was

    • set the format version of the file, or remove it

      Parameters

      • version: number | undefined

      Returns this

      RangeError if version is not a safe integer

    • set the place in the page order of the page last open, or remove it

      Parameters

      • page: number | undefined

      Returns this

      Warning: a page past the last one listed is kept, and the device opens the document at its end.

      RangeError if page is not an integer from 0 to 2^32 - 1

    • set the line height, undefined for the device's own

      Parameters

      • height: number | undefined

      Returns this

      RangeError if height is not an integer from 0 to 2^32 - 1

    • set the margins, in pixels

      Parameters

      • margins: number

      Returns this

      RangeError if margins is not an integer from 0 to 2^32 - 1

    • set originalPageCount, the number of pages of the file the document was made from, or remove it

      Parameters

      • count: number | undefined

      Returns this

      Warning: a count the pdf or epub does not have leaves the file at odds with itself. Prefer setPages, which sets it with the ids.

      RangeError if count is not a safe integer

    • set an epub's page ids to count

      It keeps the ids the document lists in order, drops those past count, and adds new ones after, then sets redirectionPageMap to 0..count, and pageCount and originalPageCount to count, as setPages does. The page count of an epub is a layout the device works out, so this lets a reader that laid it out itself give it ids, as the reMarkable Mac app does. It reads the document's file list to check it has no pdf, which would fix the count. Until this settles, an edit, a push or a pull of it throws a PutRunningError.

      Parameters

      • count: number

      Returns Promise<ClientDocumentContent>

      RangeError if count is not an integer from 0 to 2^32 - 1

      ContentEditError with reason "hasPdf" if the document has a pdf, "notEpub" if it is not an epub, or "hasPageList" if its .content has cPages; it is then left as it was

    • set the whole page list, cPages, or remove it

      Parameters

      Returns this

      Warning: the list is written as given: timestamps that do not order after the ones another copy holds lose a merge to them, an author table that lacks an author of a timestamp cannot be merged, and a list beside pages hides it from the device. A pageCount that no longer counts the pages leaves the file at odds with itself. Prefer the page edits, such as addPage, which stamp each change.

    • set the page ids of a document without cPages, as the reMarkable Mac app does on opening a document the tablet never laid out

      It sets pages to pages, redirectionPageMap to 0..n, and pageCount and originalPageCount to n, the number of ids, so each page shows the page of the file at its place. The page edits, such as addPage, can then be made.

      Parameters

      • pages: string[]

      Returns this

      ContentEditError with reason "hasPageList" if the document has cPages, or "duplicatePage" if pages lists an id twice

    • set pageCount, the number of pages, alone

      Parameters

      • count: number

      Returns this

      Warning: a count that does not count the pages cPages or pages lists leaves the file at odds with itself. A page edit such as addPage keeps the count matching, and setPages sets it with the ids.

      RangeError if count is not a safe integer

    • set the pages list alone: undefined removes it, and null writes it as null

      Parameters

      • pages: string[] | null | undefined

      Returns this

      Warning: this writes no redirectionPageMap, pageCount or originalPageCount, so it can leave counts that do not match the ids, a map that points past them, the same id twice, or ids beside a cPages that the device reads instead. Prefer setPages, which writes them together and refuses those.

    • set redirectionPageMap alone, or remove it: for each page of pages, the page of the pdf or epub it shows, or -1 for a page added

      Parameters

      • map: number[] | undefined

      Returns this

      Warning: a map of another length than pages, or one that points past the file's pages, leaves the file at odds with itself. Prefer setPages and the page edits, such as addPage, which keep it matching.

      RangeError if a page of map is not a safe integer

    • set the size the file says the document has, as text, or remove it

      Parameters

      • size: string | undefined

      Returns this

    • set the tags, with when each was added, or remove them; tags are written bare, as older firmware writes them, when none has a time, and a tag without one is otherwise written as added at the epoch

      Parameters

      • tags: Tag[] | undefined

      Returns this

      Warning: a merge orders tags by when they were added, so a tag dated earlier than a copy elsewhere removed it stays removed. Prefer addTag and removeTag, which date the edit now.

    • read a document's .content from what toJSON gave, or a copy of it, as read from the account at at; the core checks every field

      Parameters

      • value: unknown
      • at: Date = ...

      Returns DocumentContent

      TypeError if value is not an object

    • read a document's .content from its bytes, read from the account at at

      A field the file leaves out or writes as null reads as in a new document's, a whole number written as 1.0 reads as that number, and a file without fileType reads as a notebook.

      Parameters

      • bytes: Uint8Array
      • at: Date = ...

      Returns DocumentContent