# PDF から制限を削除する
PDF のすべての権限制限をリセットし、コピー、印刷、編集を復元します。
PDF ドキュメントからすべての権限制限を削除し、コピー、印刷、編集を行える状態に戻します。この API はステートレスです。ドキュメントはリージョン内で処理され、保存されることはありません。
<Note>
これは権限フラグ(コピー、印刷、編集の制限)をリセットするものであり、ファイルを開くために必要なパスワードではありません。パスワードを削除するには、[パスワードの削除](/docs/api/remove-password-from-pdf)を使用してください。ライフサイクル全体については、[ドキュメントの保護](/docs/api/protecting-documents)を参照してください。
</Note>
## エンドポイント
<Endpoint method="POST" path="/v1/remove_restrictions" />
すべてのリージョンで利用できます。ルーティングとデータレジデンシーについては、[リージョンとデータレジデンシー](/docs/api/regions-and-data-residency)を参照してください。
| リージョン | URL |
| -------------- | ---------------------------------------------------- |
| グローバル | `https://api.pdfblocks.com/v1/remove_restrictions` |
| 日本 | `https://jp.api.pdfblocks.com/v1/remove_restrictions` |
| 米国 | `https://us.api.pdfblocks.com/v1/remove_restrictions` |
| HIPAA 米国 | `https://hipaa.api.pdfblocks.com/v1/remove_restrictions` |
| 欧州連合 | `https://eu.api.pdfblocks.com/v1/remove_restrictions` |
| 英国 | `https://uk.api.pdfblocks.com/v1/remove_restrictions` |
| カナダ | `https://ca.api.pdfblocks.com/v1/remove_restrictions` |
| オーストラリア | `https://au.api.pdfblocks.com/v1/remove_restrictions` |
| インド | `https://in.api.pdfblocks.com/v1/remove_restrictions` |
| ブラジル | `https://br.api.pdfblocks.com/v1/remove_restrictions` |
## 認証
すべてのリクエストは、HTTPS 経由で `X-API-Key` ヘッダーにシークレット API キーを設定して認証してください。キーの作成と管理は[ダッシュボード](https://dashboard.pdfblocks.com)から行います。詳細は[認証](/docs/api/authentication)を参照してください。
## リクエスト
このエンドポイントは `multipart/form-data` 形式のリクエストボディを受け付けます。
<ParamField name="file" type="file" required>
入力 PDF ドキュメントです。
</ParamField>
## 例
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>
## レスポンス
成功すると、制限のない PDF を本文とする `200 OK` が返されます。
```http
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 48213
```
出力は、権限フラグがリセットされた同じドキュメントです。ページと内容は変更されません。上記の例のように、レスポンスの本文はそのままファイルにストリーミングしてください。サーバー側には何も保存されません。
## エラー
リクエストが失敗した場合は、`application/problem+json` 形式のボディが返されます。このエンドポイントで最も多いのは `400` で、`file` が読み取り可能な PDF でない場合に返されます。`errors` オブジェクトに該当するフィールド名が示されます:
```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."]
}
}
```
`X-API-Key` が指定されていないか無効な場合は `401` が返されます。すべてのステータスコードとレスポンスの完全な形式については、[エラー](/docs/api/errors)を参照してください。
## 関連アクション
<CardGroup cols={2}>
<Card title="制限を追加" href="/docs/api/add-restrictions-to-pdf">
権限フラグを再度適用します。
</Card>
<Card title="パスワードを削除" href="/docs/api/remove-password-from-pdf">
代わりに開くためのパスワードを削除します。
</Card>
<Card title="パスワードを追加" href="/docs/api/add-password-to-pdf">
パスワードでドキュメントを暗号化します。
</Card>
<Card title="署名を削除" href="/docs/api/remove-signatures-from-pdf">
ドキュメントから署名を削除します。
</Card>
</CardGroup>
PDF から制限を削除する
PDF のすべての権限制限をリセットし、コピー、印刷、編集を復元します。
PDF ドキュメントからすべての権限制限を削除し、コピー、印刷、編集を行える状態に戻します。この API はステートレスです。ドキュメントはリージョン内で処理され、保存されることはありません。
エンドポイント
POST
/v1/remove_restrictionsすべてのリージョンで利用できます。ルーティングとデータレジデンシーについては、リージョンとデータレジデンシーを参照してください。
| リージョン | URL |
|---|---|
| グローバル | https://api.pdfblocks.com/v1/remove_restrictions |
| 日本 | https://jp.api.pdfblocks.com/v1/remove_restrictions |
| 米国 | https://us.api.pdfblocks.com/v1/remove_restrictions |
| HIPAA 米国 | https://hipaa.api.pdfblocks.com/v1/remove_restrictions |
| 欧州連合 | https://eu.api.pdfblocks.com/v1/remove_restrictions |
| 英国 | https://uk.api.pdfblocks.com/v1/remove_restrictions |
| カナダ | https://ca.api.pdfblocks.com/v1/remove_restrictions |
| オーストラリア | https://au.api.pdfblocks.com/v1/remove_restrictions |
| インド | https://in.api.pdfblocks.com/v1/remove_restrictions |
| ブラジル | https://br.api.pdfblocks.com/v1/remove_restrictions |
認証
すべてのリクエストは、HTTPS 経由で X-API-Key ヘッダーにシークレット API キーを設定して認証してください。キーの作成と管理はダッシュボードから行います。詳細は認証を参照してください。
リクエスト
このエンドポイントは multipart/form-data 形式のリクエストボディを受け付けます。
filefilerequired入力 PDF ドキュメントです。
例
PDF からすべての権限制限を削除する例。
curl https://api.pdfblocks.com/v1/remove_restrictions \
-H 'X-API-Key: your_api_key' \
-F file=@input.pdf \
-o unrestricted.pdf# 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)// 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
$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);
}# 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?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)
}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());レスポンス
成功すると、制限のない PDF を本文とする 200 OK が返されます。
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 48213出力は、権限フラグがリセットされた同じドキュメントです。ページと内容は変更されません。上記の例のように、レスポンスの本文はそのままファイルにストリーミングしてください。サーバー側には何も保存されません。
エラー
リクエストが失敗した場合は、application/problem+json 形式のボディが返されます。このエンドポイントで最も多いのは 400 で、file が読み取り可能な PDF でない場合に返されます。errors オブジェクトに該当するフィールド名が示されます:
{
"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."]
}
}X-API-Key が指定されていないか無効な場合は 401 が返されます。すべてのステータスコードとレスポンスの完全な形式については、エラーを参照してください。