PDF Blocks
料金サポート
無料で始める
ページへ移動

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 からすべての権限制限を削除する例。

cURLbash
curl https://api.pdfblocks.com/v1/remove_restrictions \
  -H 'X-API-Key: your_api_key' \
  -F file=@input.pdf \
  -o unrestricted.pdf
Pythonpython
# 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.jsjavascript
// 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()));
PHPphp
<?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);
}
Rubyruby
# 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?
Gogo
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)
}
C#csharp
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 が返されます。すべてのステータスコードとレスポンスの完全な形式については、エラーを参照してください。

関連アクション