# Die Einschränkungen aus einem PDF entfernen

Setzen Sie alle Berechtigungseinschränkungen eines PDFs zurück und geben Sie Kopieren, Drucken und Bearbeiten wieder frei.

Entfernen Sie alle Berechtigungseinschränkungen aus einem PDF-Dokument und
stellen Sie damit die Möglichkeit zum Kopieren, Drucken und Bearbeiten wieder
her. Die API ist *stateless*: Ihr Dokument wird in der Region verarbeitet und
niemals gespeichert.

<Note>
  Dies setzt die Berechtigungs-Flags zurück (die Einschränkungen für Kopieren,
  Drucken und Bearbeiten), nicht das Passwort, das zum Öffnen der Datei nötig
  ist. Um dieses zu entfernen, verwenden Sie [Passwort
  entfernen](/docs/api/remove-password-from-pdf). Zum vollständigen
  Lebenszyklus siehe [Dokumente schützen](/docs/api/protecting-documents).
</Note>

## Endpoint

<Endpoint method="POST" path="/v1/remove_restrictions" />

In allen Regionen verfügbar. Hinweise zu Routing und Datenresidenz finden Sie
unter [Regionen und Datenresidenz](/docs/api/regions-and-data-residency).

| Region                 | URL                                                      |
| ---------------------- | -------------------------------------------------------- |
| Global                 | `https://api.pdfblocks.com/v1/remove_restrictions`       |
| USA                    | `https://us.api.pdfblocks.com/v1/remove_restrictions`    |
| HIPAA USA              | `https://hipaa.api.pdfblocks.com/v1/remove_restrictions` |
| Europäische Union      | `https://eu.api.pdfblocks.com/v1/remove_restrictions`    |
| Vereinigtes Königreich | `https://uk.api.pdfblocks.com/v1/remove_restrictions`    |
| Kanada                 | `https://ca.api.pdfblocks.com/v1/remove_restrictions`    |
| Australien             | `https://au.api.pdfblocks.com/v1/remove_restrictions`    |
| Japan                  | `https://jp.api.pdfblocks.com/v1/remove_restrictions`    |
| Indien                 | `https://in.api.pdfblocks.com/v1/remove_restrictions`    |
| Brasilien              | `https://br.api.pdfblocks.com/v1/remove_restrictions`    |

## Authentifizierung

Authentifizieren Sie jede Anfrage mit Ihrem geheimen API-Schlüssel im Header
`X-API-Key`, über HTTPS. Schlüssel erstellen und verwalten Sie im
[Dashboard](https://dashboard.pdfblocks.com). Einzelheiten finden Sie unter
[Authentifizierung](/docs/api/authentication).

## Anfrage

Der Endpoint nimmt einen Anfragetext vom Typ `multipart/form-data` entgegen.

<ParamField name="file" type="file" required>
  Das PDF-Eingabedokument.
</ParamField>

## Beispiele

Entfernen Sie alle Berechtigungseinschränkungen aus einem PDF:

<CodeGroup>

```bash title="cURL"
curl https://api.pdfblocks.com/v1/remove_restrictions \
  -H 'X-API-Key: your_api_key' \
  -F file=@input.pdf \
  -o unrestricted.pdf
```

```python title="Python"
# pip install requests
import requests

with open('input.pdf', 'rb') as file:
    response = requests.post(
        'https://api.pdfblocks.com/v1/remove_restrictions',
        headers={'X-API-Key': 'your_api_key'},
        files={'file': file},
    )

response.raise_for_status()
with open('unrestricted.pdf', 'wb') as output:
    output.write(response.content)
```

```javascript title="Node.js"
// Node.js 18+
import { readFile, writeFile } from 'node:fs/promises';

const body = new FormData();
body.set('file', new Blob([await readFile('input.pdf')]), 'input.pdf');

const response = await fetch('https://api.pdfblocks.com/v1/remove_restrictions', {
  method: 'POST',
  headers: { 'X-API-Key': 'your_api_key' },
  body,
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
await writeFile('unrestricted.pdf', Buffer.from(await response.arrayBuffer()));
```

```php title="PHP"
<?php
$ch = curl_init('https://api.pdfblocks.com/v1/remove_restrictions');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['X-API-Key: your_api_key'],
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'file' => new CURLFile('input.pdf', 'application/pdf'),
    ],
]);

$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
    file_put_contents('unrestricted.pdf', $pdf);
}
```

```ruby title="Ruby"
# gem install http
require 'http'

response = HTTP
  .headers('X-API-Key' => 'your_api_key')
  .post('https://api.pdfblocks.com/v1/remove_restrictions', form: {
    file: HTTP::FormData::File.new('input.pdf'),
  })

File.write('unrestricted.pdf', response.body) if response.status.success?
```

```go title="Go"
package main

import (
	"bytes"
	"io"
	"mime/multipart"
	"net/http"
	"os"
)

func main() {
	var buf bytes.Buffer
	form := multipart.NewWriter(&buf)

	file, _ := os.Open("input.pdf")
	defer file.Close()
	part, _ := form.CreateFormFile("file", "input.pdf")
	io.Copy(part, file)

	form.Close()

	req, _ := http.NewRequest("POST", "https://api.pdfblocks.com/v1/remove_restrictions", &buf)
	req.Header.Set("Content-Type", form.FormDataContentType())
	req.Header.Set("X-API-Key", "your_api_key")

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

	out, _ := os.Create("unrestricted.pdf")
	defer out.Close()
	io.Copy(out, res.Body)
}
```

```csharp title="C#"
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "your_api_key");

using var form = new MultipartFormDataContent
{
    { new ByteArrayContent(File.ReadAllBytes("input.pdf")), "file", "input.pdf" },
};

var response = await client.PostAsync(
    "https://api.pdfblocks.com/v1/remove_restrictions", form);
response.EnsureSuccessStatusCode();
await File.WriteAllBytesAsync(
    "unrestricted.pdf", await response.Content.ReadAsByteArrayAsync());
```

</CodeGroup>

## Antwort

Bei Erfolg lautet die Antwort `200 OK` und enthält das PDF ohne Einschränkungen
als Antworttext:

```http
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 48213
```

Die Ausgabe ist dasselbe Dokument mit zurückgesetzten Berechtigungs-Flags: Seine
Seiten und sein Inhalt sind unverändert. Schreiben Sie den Antworttext direkt in
eine Datei, wie die Beispiele oben es tun; bei uns wird nichts gespeichert.

## Fehler

Fehlgeschlagene Anfragen liefern einen Antworttext vom Typ
`application/problem+json`. Am häufigsten ist bei diesem Endpoint der Status
`400`, der zurückgegeben wird, wenn `file` kein lesbares PDF ist. Das Objekt
`errors` nennt jedes betroffene Feld:

```json
{
  "type": "https://www.pdfblocks.com/docs/api/v1/error/400",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "file": ["Could not parse the PDF document. The file may be invalid or corrupt."]
  }
}
```

Ein fehlender oder ungültiger `X-API-Key` gibt einen `401` zurück. Alle
Statuscodes und die vollständige Form der Antwort finden Sie unter
[Fehler](/docs/api/errors).

## Verwandte Aktionen

<CardGroup cols={2}>

<Card title="Einschränkungen hinzufügen" href="/docs/api/add-restrictions-to-pdf">
  Berechtigungs-Flags erneut anwenden.
</Card>

<Card title="Passwort entfernen" href="/docs/api/remove-password-from-pdf">
  Stattdessen das Passwort zum Öffnen entfernen.
</Card>

<Card title="Passwort hinzufügen" href="/docs/api/add-password-to-pdf">
  Das Dokument mit einem Passwort verschlüsseln.
</Card>

<Card title="Signaturen entfernen" href="/docs/api/remove-signatures-from-pdf">
  Signaturen aus einem Dokument entfernen.
</Card>

</CardGroup>
