> ## 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 Java SDK in less than 15 lines.

# Quickstart

## Convert a local file

```java theme={null}
import tech.markpdf.MarkpdfClient;
import tech.markpdf.ConvertOptions;
import tech.markpdf.ConvertResult;
import java.nio.file.Path;

MarkpdfClient client = new MarkpdfClient("YOUR_API_KEY");

ConvertOptions options = ConvertOptions.builder()
    .mode(ConvertOptions.Mode.FAST)
    .build();

ConvertResult result = client.convertFile(Path.of("report.pdf"), options);

if (result instanceof ConvertResult.Markdown md) {
    System.out.println(md.markdown());
}
```

## Convert bytes to memory

```java theme={null}
byte[] data = java.nio.file.Files.readAllBytes(Path.of("report.pdf"));
ConvertResult result = client.convertBytes(data, "report.pdf", ConvertOptions.defaults());
```

## Convert from URL

```java theme={null}
ConvertResult result = client.convertFromUrl(
    "https://bucket.example.com/report.pdf?sig=...",
    "report.pdf",
    ConvertOptions.builder().mode(ConvertOptions.Mode.FAST).build()
);
```

## Request metadata in addition to Markdown

```java theme={null}
ConvertOptions options = ConvertOptions.builder()
    .responseFormat(ConvertOptions.ResponseFormat.JSON)
    .build();

ConvertResult result = client.convertBytes(data, "report.pdf", options);

if (result instanceof ConvertResult.Json json) {
    System.out.println(json.result().markdown());
    System.out.println(json.result().engine());
    System.out.println(json.result().timings().totalRequestMs());
}
```

`ConvertResult` is a sealed interface with records — use pattern matching (`instanceof` with binding, or `switch`) to unpack it. See [Reference](/docs/sdks/java/reference).

## Asynchronous conversion with `CompletableFuture`

```java theme={null}
client.convertBytesAsync(data, "report.pdf", ConvertOptions.defaults())
    .thenAccept(result -> {
        if (result instanceof ConvertResult.Markdown md) {
            System.out.println(md.markdown());
        }
    })
    .exceptionally(err -> {
        err.printStackTrace();
        return null;
    });
```

See [Streaming and async](/docs/sdks/java/streaming-and-async) for more details on `CompletableFuture` and jobs `202`.

## Siguiente paso

* [Full customer reference](/docs/sdks/java/reference)
* [Async y jobs (202)](/docs/sdks/java/streaming-and-async)
* [Error Handling](/docs/sdks/java/error-handling)
