Das Passwort aus einem PDF entfernen
Entschlüsseln Sie ein passwortgeschütztes PDF, sodass es zum Öffnen kein Passwort mehr verlangt.
Entfernen Sie das Passwort aus einem verschlüsselten PDF. Geben Sie das Passwort an, das die Datei derzeit öffnet, und Sie erhalten ein Dokument zurück, das sich ohne Passwort öffnen lässt. Die API ist stateless: Ihr Dokument wird in der Region verarbeitet und niemals gespeichert.
Endpoint
/v1/remove_passwordIn allen Regionen verfügbar. Hinweise zu Routing und Datenresidenz finden Sie unter Regionen und Datenresidenz.
| Region | URL |
|---|---|
| Global | https://api.pdfblocks.com/v1/remove_password |
| USA | https://us.api.pdfblocks.com/v1/remove_password |
| HIPAA USA | https://hipaa.api.pdfblocks.com/v1/remove_password |
| Europäische Union | https://eu.api.pdfblocks.com/v1/remove_password |
| Vereinigtes Königreich | https://uk.api.pdfblocks.com/v1/remove_password |
| Kanada | https://ca.api.pdfblocks.com/v1/remove_password |
| Australien | https://au.api.pdfblocks.com/v1/remove_password |
| Japan | https://jp.api.pdfblocks.com/v1/remove_password |
| Indien | https://in.api.pdfblocks.com/v1/remove_password |
| Brasilien | https://br.api.pdfblocks.com/v1/remove_password |
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. Einzelheiten finden Sie unter
Authentifizierung.
Anfrage
Der Endpoint nimmt einen Anfragetext vom Typ multipart/form-data entgegen.
filefilerequiredDas verschlüsselte PDF-Eingabedokument.
passwordstringrequiredDas Passwort, das die Datei derzeit öffnet. Maximal 256 Zeichen.
Das Passwort zu entfernen setzt voraus, dass Sie es kennen: Geben Sie das Passwort an, das das Dokument derzeit öffnet. Es gibt keinen Weg zur Wiederherstellung und kein Ausprobieren per Brute Force.
Beispiele
Entfernen Sie das Passwort aus einem verschlüsselten PDF:
curl https://api.pdfblocks.com/v1/remove_password \
-H 'X-API-Key: your_api_key' \
-F file=@input.pdf \
-F password='0pen-Sesame' \
-o unlocked.pdf# pip install requests
import requests
with open('input.pdf', 'rb') as file:
response = requests.post(
'https://api.pdfblocks.com/v1/remove_password',
headers={'X-API-Key': 'your_api_key'},
files={'file': file},
data={'password': '0pen-Sesame'},
)
response.raise_for_status()
with open('unlocked.pdf', 'wb') as output:
output.write(response.content)// 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');
body.set('password', '0pen-Sesame');
const response = await fetch('https://api.pdfblocks.com/v1/remove_password', {
method: 'POST',
headers: { 'X-API-Key': 'your_api_key' },
body,
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
await writeFile('unlocked.pdf', Buffer.from(await response.arrayBuffer()));<?php
$ch = curl_init('https://api.pdfblocks.com/v1/remove_password');
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'),
'password' => '0pen-Sesame',
],
]);
$pdf = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
file_put_contents('unlocked.pdf', $pdf);
}# gem install http
require 'http'
response = HTTP
.headers('X-API-Key' => 'your_api_key')
.post('https://api.pdfblocks.com/v1/remove_password', form: {
file: HTTP::FormData::File.new('input.pdf'),
password: '0pen-Sesame',
})
File.write('unlocked.pdf', response.body) if response.status.success?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.WriteField("password", "0pen-Sesame")
form.Close()
req, _ := http.NewRequest("POST", "https://api.pdfblocks.com/v1/remove_password", &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("unlocked.pdf")
defer out.Close()
io.Copy(out, res.Body)
}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" },
{ new StringContent("0pen-Sesame"), "password" },
};
var response = await client.PostAsync(
"https://api.pdfblocks.com/v1/remove_password", form);
response.EnsureSuccessStatusCode();
await File.WriteAllBytesAsync(
"unlocked.pdf", await response.Content.ReadAsByteArrayAsync());Antwort
Bei Erfolg lautet die Antwort 200 OK und enthält das entschlüsselte PDF als
Antworttext:
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 48213Das Ausgabedokument verlangt zum Öffnen kein Passwort mehr: 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 das angegebene password die Datei nicht
öffnet. Das Objekt errors nennt jedes betroffene Feld:
{
"type": "https://www.pdfblocks.com/docs/api/v1/error/400",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"password": ["The password is incorrect."]
}
}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.