> ## Documentation Index
> Fetch the complete documentation index at: https://docs.markpdf.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Your first conversion with Kotlin SDK in less than 15 lines.

# Quickstart

All client methods are `suspend fun` — call them from a coroutine (`runBlocking`, `viewModelScope`, a suspended Ktor/Spring WebFlux endpoint, etc.).

## Convert a local file

```kotlin theme={null}
import kotlinx.coroutines.runBlocking
import tech.markpdf.MarkpdfClient
import tech.markpdf.ConvertOptions
import tech.markpdf.ConvertResult
import java.io.File

fun main() = runBlocking {
    val client = MarkpdfClient(apiKey = "YOUR_API_KEY")

    val result = client.convertFile(File("report.pdf"), ConvertOptions(mode = ConversionMode.FAST))

    when (result) {
        is ConvertResult.Markdown -> println(result.markdown)
        else -> {}
    }
}
```

## Convert bytes to memory

```kotlin theme={null}
val bytes = File("report.pdf").readBytes()
val result = client.convertBytes(bytes, "report.pdf")
```

## Convert from URL

```kotlin theme={null}
val result = client.convertFromUrl(
    url = "https://bucket.example.com/report.pdf?sig=...",
    filename = "report.pdf",
    options = ConvertOptions(mode = ConversionMode.FAST),
)
```

## Request metadata in addition to Markdown

```kotlin theme={null}
val result = client.convertBytes(
    bytes, "report.pdf",
    options = ConvertOptions(responseFormat = ResponseFormat.JSON),
)

when (result) {
    is ConvertResult.Json -> {
        println(result.result.markdown)
        println(result.result.engine)
        println(result.result.timings.totalRequestMs)
    }
    else -> {}
}
```

`ConvertResult` is a sealed class — use `when` exhaustive to unpack it. See [Reference](/docs/sdks/kotlin/reference).

## Siguiente paso

* [Full customer reference](/docs/sdks/kotlin/reference)
* [Coroutines and asynchronous jobs (202)](/docs/sdks/kotlin/streaming-and-async)
* [Error Handling](/docs/sdks/kotlin/error-handling)
