> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.coperniq.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.coperniq.io/_mcp/server.

# Export Form as PDF

POST https://api.coperniq.io/v1/forms/{form_id}/pdf
Content-Type: application/json

Export a form to PDF. All body fields are optional.


Reference: https://docs.coperniq.io/api-reference/forms/get-form-pdf

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Request

### Path parameters

- `form_id` (integer, required) — Form identifier

### Body (application/json)

This endpoint expects an object.

- `imagesOnly` (boolean, optional) — Export only the form's image fields, omitting other field types. Defaults to false.
- `imagesInRow` (enum, optional) — Number of images to lay out per row. Defaults to 2.
  - Allowed values: `0`, `1`, `2`, `3`, `4`, `5`, `6`
- `includeImageMetadata` (boolean, optional) — Include image metadata (e.g. GPS, timestamp) below each image. Defaults to true.

## Response

### 200

PDF generated successfully

- `pdfBase64` (string, required) — Base64-encoded PDF bytes
- `contentType` (enum, required)
  - Allowed values: `application/pdf`
- `name` (string, optional, nullable) — Suggested file name for the exported PDF

## Errors

### 400 Bad Request Error

Invalid request

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`
- `field` (string, optional) — Field that caused the validation error (if applicable)

### 401 Unauthorized Error

Authentication failed

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`

### 404 Not Found Error

Resource not found

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`

### 500 Internal Server Error

Internal server error

- `message` (string, optional)
- `code` (enum, optional)
  - Allowed values: `INTERNAL_SERVER_ERROR`

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "pdfBase64": "string",
  "contentType": "application/pdf",
  "name": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.coperniq.io/v1/forms/1/pdf"

payload = {}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.coperniq.io/v1/forms/1/pdf';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.coperniq.io/v1/forms/1/pdf"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.coperniq.io/v1/forms/1/pdf")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.coperniq.io/v1/forms/1/pdf")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.coperniq.io/v1/forms/1/pdf', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.coperniq.io/v1/forms/1/pdf");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.coperniq.io/v1/forms/1/pdf")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```