> ## 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 markpdf-cpp in less than 15 lines.

# Quickstart

## Convert a local file

```cpp theme={null}
#include <markpdf/client.hpp>
#include <iostream>

int main() {
    markpdf::Client client("YOUR_API_KEY");

    markpdf::ConvertOptions opts;
    opts.mode = markpdf::Mode::Fast;

    auto result = client.convertFile("report.pdf", opts);
    if (!result) {
        std::cerr << "Error: " << result.error().detail << "\n";
        return 1;
    }
    std::cout << result->markdown << "\n";
}
```

`convertFile` returns `markpdf::Result<ConversionResult, MarkpdfError>` — a type like `expected<T, E>` (similar to C++23's `std::expected`, available here as its own C++17-compatible implementation). Check with `if (!result)` before accessing the value.

## Convert from URL

```cpp theme={null}
auto result = client.convertFromUrl("https://bucket.example.com/report.pdf?sig=...");
if (result) {
    std::cout << result->markdown;
}
```

## CMakeLists.txt minimum

```cmake theme={null}
cmake_minimum_required(VERSION 3.16)
project(mi_app CXX)

include(FetchContent)
FetchContent_Declare(markpdf-cpp GIT_REPOSITORY https://github.com/markpdf/markpdf-cpp.git GIT_TAG v1.0.0)
FetchContent_MakeAvailable(markpdf-cpp)

add_executable(mi_app main.cpp)
target_link_libraries(mi_app PRIVATE markpdf::markpdf)
target_compile_features(mi_app PRIVATE cxx_std_17)
```

## Request metadata in addition to Markdown

```cpp theme={null}
markpdf::ConvertOptions opts;
opts.responseFormat = markpdf::ResponseFormat::Json;

auto result = client.convertFile("report.pdf", opts);
if (result) {
    std::cout << result->engine << "\n";
    std::cout << result->timings.totalRequestMs << " ms\n";
    std::cout << result->tokenSavedEstimate << " tokens ahorrados\n";
}
```

## Siguiente paso

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