Lewati ke konten utama

Enkripsi Dokumen PDF API

PDF4me Lindungi Dokumen adalah endpoint REST yang melindungi PDF dengan kata sandi dan membatasi apa yang dapat dilakukan penerima terhadapnya. Kirim file tersebut sebagai Base64 ke /api/v2/Protect Dengan kata sandi dan flag izin, dan responsnya adalah PDF baru yang dienkripsi AES. Pencetakan, penyalinan, pengeditan, dan pengisian formulir hanya diperbolehkan jika Anda mengizinkannya.

Fungsi dari endpoint ini

PDF4me Lindungi Dokumen mengenkripsi sebuah PDF dengan kata sandi dan mengatur bendera izin dalam satu REST Telepon. Kirim PDF sebagai Base64, pilih kata sandi dan tindakan mana yang diizinkan (mencetak, menyalin, memberi anotasi, mengisi formulir), dan terima yang baru AES-terenkripsi PDF dalam respons. Enkripsi yang diterapkan adalah AES-128 atau AES-256 menurut PDF spesifikasi, cocok untuk GDPR, HIPAAdan alur kerja berbasis kepatuhan lainnya.

Postingan Blog Terkait
Belum ada postingan blog untuk fitur ini — akan segera hadir.
Sementara itu, jelajahi blog PDF4me untuk menemukan tutorial dan alur kerja di berbagai platform.
Kunjungi blog ini

Memverifikasi Identitas Anda API Meminta

Setiap PDF4me REST API panggilan harus menyertakan Anda API kunci di Authorization header. Buat atau pilih kunci dari dasbor pengembang dan simpan di sisi server. Jangan pernah mengeksposnya dalam kode browser.

Fakta Penting yang Tidak Boleh Anda Lewatkan

Kata sandi dan izin diterapkan secara bersamaan.
Single kata sandi Pembukaan dokumen gerbang lapangan. Itu Izin PDF Enum mengontrol apa yang dapat dilakukan pengguna setelah dokumen dibuka. Gunakan keduanya bersama-sama untuk mengirimkan sebuah PDF yang memerlukan kata sandi DAN menonaktifkan pencetakan atau penyalinan.
Bendera izin adalah daftar izin, bukan daftar penolakan.
Apa pun yang tidak Anda sertakan di dalam Izin PDF diblokir. Atur ke Tidak ada untuk memblokir setiap tindakan kecuali membuka, atau ke bendera tertentu seperti Isi Formulir hanya mengizinkan pengisian formulir dan tidak ada yang lain.
Sumber PDF tidak pernah dimodifikasi
Yang API mengembalikan yang terenkripsi PDF Sebagai byte biner mentah dalam isi respons (Content-Type application/pdf). File asli Anda tetap utuh. Tulis byte respons langsung ke file .pdf baru. Berguna untuk jejak audit kepatuhan di mana sumber yang tidak terlindungi harus tetap utuh.

REST API titik akhir

Metode: POS
URL: https://api.pdf4me.com/api/v2/Protect

Mengirim Content-Type: application/json dan sebuah Otorisasi header dengan milik Anda API kunci. Atur asinkron ke PALSU untuk respons sinkron (HTTP 200 dengan yang terenkripsi PDF sebagai byte biner mentah), atau BENAR untuk menerima HTTP 202 ditambah a Lokasi header yang Anda periksa terus-menerus hingga mengembalikan kode 200 dengan nilai biner. PDF.

Pengaturan permintaan Postman

PengaturanNilai
MethodPOST
URLhttps://api.pdf4me.com/api/v2/Protect
HeadersContent-Type: application/json
AuthorizationBasic Auth with your API key, or header Authorization: Basic YOUR_API_KEY
Bodyraw JSON with docContent, docName, password, pdfPermission, and async fields
Response (sync)When async is false: HTTP 200 with the encrypted PDF as raw binary bytes. Save the response body directly to a .pdf file.
Response (async)When async is true: HTTP 202 with a Location header. GET that URL until you receive 200 plus the binary PDF. Useful for large files or slow networks.

Parameter

Selalu diperlukan: Konten dokumen, Nama dokumen, kata sandi, Izin PDF. Itu asinkron flag bersifat opsional (nilai defaultnya adalah PALSU) dan mengontrol apakah respons dikembalikan segera atau melalui URL polling.

ParameterDiperlukanJenisApa fungsinya?Contoh
docContentRequiredBase64 StringThe source PDF file encoded as Base64 (no data: prefix). Read the file as bytes and run it through your language's Base64 encoder.JVBERi0xLjQK...
docNameRequiredStringFilename of the source PDF including the .pdf extension. Used for tracking and the output filename.invoice.pdf
passwordRequiredStringThe password applied to the encrypted PDF. Users must enter this to open the document.Str0ng-P@ss!
pdfPermissionRequiredEnumWhat the user can do once the PDF is unlocked. One of: All, None, Copy, Annotate, Fill Forms, Support Disabilities, Assemble, Digital Print. See the flag reference card grid below.Fill Forms
asyncOptionalBooleanDefaults to false. When false the API returns the encrypted PDF immediately as binary bytes (HTTP 200). When true the API returns HTTP 202 with a Location header; poll that URL with GET until you receive 200 with the binary PDF. Use true for large PDFs or batch processing.false

Bendera pdfPermission mana yang harus saya pilih?

Kata sandi dan flag izin melindungi dari hal yang berbeda. Kata sandi mengatur pembukaan gerbang; flag izin mengatur apa yang terjadi setelah pembukaan.

Kata sandi vs izinpassword bidangpdfPermission bidang
Melindungi terhadapPembukaan tanpa izinTindakan yang tidak diinginkan setelah pembukaan
Siapa yang terdampakSemua orang tanpa kata sandiSemua orang yang membuka dokumen tersebut
Penggunaan umumPengiriman rahasiaKontrak hanya baca, salinan bukti
Nilai paling ketatKata sandi unik yang kuatNone (hanya buka)
SemuaSegala sesuatu diperbolehkan.
Buka, cetak, salin, edit, beri anotasi, isi formulir. Gunakan untuk perlindungan hanya dengan kata sandi tanpa batasan lebih lanjut.
Tidak adaHanya buka
Memblokir pencetakan, penyalinan, pengeditan, anotasi, pengisian formulir. Opsi yang paling terbatas.
MenyalinBuka dan salin teks atau gambar.
Mencetak blok, mengedit, dan memberi anotasi.
Membubuhi keteranganBuka dan beri anotasi
Penggunaan catatan tempel dan stabilo diperbolehkan. Dilarang menyalin, mencetak, dan mengedit.
Isi FormulirBuka dan isi kolom formulir.
Blok pencetakan, penyalinan, pengeditan. Umum digunakan untuk formulir penerimaan informasi rahasia.
Dukungan bagi Penyandang DisabilitasBuka dengan alat aksesibilitas
Akses pembaca layar dan alat bantu. Diperlukan untuk PDF yang secara default dapat diakses.
BerkumpulPerubahan tingkat halaman diperbolehkan
Sisipkan, hapus, atau putar halaman. Digunakan ketika perangkat lunak hilir perlu menyusun ulang PDF.
Cetak DigitalHanya cetakan resolusi rendah
Memblokir pencetakan dan penggandaan resolusi tinggi. Berguna untuk salinan percobaan.

Minta contoh

Contoh A: Enkripsi hanya dengan kata sandi (All izin)

{
"docContent": "JVBERi0xLjQK...",
"docName": "invoice.pdf",
"password": "Str0ng-P@ss!",
"pdfPermission": "All",
"async": false
}

Contoh B: Enkripsi dengan batasan maksimum (None)

Mencetak, menyalin, mengedit, memberi anotasi, dan mengisi formulir.

{
"docContent": "JVBERi0xLjQK...",
"docName": "confidential.pdf",
"password": "Str0ng-P@ss!",
"pdfPermission": "None",
"async": false
}

Contoh C: Enkripsi dan hanya izinkan pengisian formulir

Berguna untuk formulir penerimaan informasi rahasia di mana penerima harus mengisi tetapi tidak boleh mendistribusikannya kembali.

{
"docContent": "JVBERi0xLjQK...",
"docName": "intake-form.pdf",
"password": "Form-2026",
"pdfPermission": "Fill Forms",
"async": true
}

Respons berhasil (sinkronisasi, async: false)

HTTP 200 dengan yang terenkripsi PDF sebagai badan respons mentah (biner) application/pdf). TIDAK JSON pembungkus. Simpan byte respons langsung ke file.

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="protected.pdf"

<binary PDF bytes>

Respons berhasil (asinkron, async: true)

HTTP 202 dengan sebuah Location Judul. Lakukan jajak pendapat tentang itu. URL dengan GET (sama Authorization header) sampai Anda menerima HTTP 200 dengan biner PDF.

HTTP/1.1 202 Accepted
Location: https://api.pdf4me.com/api/v2/JobStatus/<job-id>

contoh curl

Mode sinkronisasi (simpan isi respons langsung ke file):

curl -X POST https://api.pdf4me.com/api/v2/Protect \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-o protected.pdf \
-d '{"docContent":"JVBERi0xLjQK...","docName":"invoice.pdf","password":"Str0ng-P@ss!","pdfPermission":"Fill Forms","async":false}'

Mode asinkron (catatan) -D headers.txt untuk menangkap Location (header untuk polling):

curl -X POST https://api.pdf4me.com/api/v2/Protect \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-D headers.txt \
-d '{"docContent":"...","docName":"invoice.pdf","password":"Str0ng-P@ss!","pdfPermission":"Fill Forms","async":true}'

Apa yang dikembalikan oleh API?

Dokumen terenkripsi itu sendiri. Perlindungan diterapkan dengan Enkripsi AES sebagaimana didefinisikan oleh Spesifikasi PDF, sehingga setiap pembaca yang sesuai standar akan meminta kata sandi dan memberlakukan flag izin.

BidangJenisIsi di dalamnya
Response body (HTTP 200)BinaryThe encrypted PDF bytes (Content-Type application/pdf). Write them straight to a new .pdf file; the source file is never modified.
Location header (HTTP 202)String (URL)Returned when async is true and processing continues in the background. GET this URL with the same Authorization header.
Poll response (HTTP 200)BinaryThe finished encrypted PDF, returned once the async job completes.
Poll response (HTTP 202)EmptyJob still processing. Wait and poll the same Location URL again.

Contoh kode

Contoh integrasi

Pola integrasi REST umumTypical ways developers call Protect Document.
Enkripsi faktur secara massal untuk pengiriman.
  1. Bacalah setiap faktur PDF dari sebuah folder, S3 bucket, atau antrian basis data.
  2. Base64-mengenkode byte dan POST untuk Melindungi dengan Izin PDF diatur ke Isi Formulir.
  3. Tulis byte respons langsung ke file .pdf (biner mentah), lalu unggah file terenkripsi tersebut ke email atau penyimpanan objek.
  4. Lakukan perulangan pada setiap file. Endpoint bersifat stateless dan aman untuk panggilan paralel dalam batas laju yang Anda tetapkan.
Enkripsi lalu tanda tangani untuk alur kerja hukum.
  1. POST sumber PDF ke /api/v2/Protect dengan kata sandi penerima dan izin yang dipilih.
  2. Ambil byte respons biner, encode ulang menjadi Base64dan memberi mereka makan sebagai Konten dokumen ke Tanda Tangan Digital titik akhir.
  3. Menerima satu PDF itu keduanya AES-Terenkripsi dan ditandatangani secara kriptografis. Tahan terhadap perubahan untuk keperluan hukum dan kepatuhan.
GDPR atau HIPAA enkripsi per penerima
  1. Buat kata sandi unik untuk setiap penerima (UUID atau yang berasal dari rahasia bersama).
  2. POST untuk melindungi dengan kata sandi tersebut dan Izin PDF diatur ke Tidak ada untuk memblokir semua penyalinan dan pencetakan.
  3. Kirimkan email yang terenkripsi PDF dan kata sandi melalui saluran terpisah untuk jejak audit kepatuhan.

Pertanyaan yang Sering Diajukan

What encryption strength does the Protect endpoint apply?+
PDF4me applies AES encryption per the PDF specification (ISO 32000). Modern PDF readers use 128-bit or 256-bit AES depending on the PDF version of the source. Both meet GDPR and HIPAA encryption requirements for documents in transit and at rest.
Can I set an owner password and a user password separately?+
The password field is applied as the user password (required to open). The pdfPermission enum is the owner-level signal controlling what is allowed once the document is open. Together they behave like a combined owner-and-user setup. The endpoint does not currently accept two distinct passwords in one call.
How do I disable printing or copying on the encrypted PDF?+
Pick a pdfPermission value that does NOT include the action you want to block. Set it to None to block everything except opening. Set it to Copy to allow text or image copy only. Set it to Fill Forms to allow form filling only. The flag is allow-list: anything not explicitly listed is blocked.
Is the original PDF modified, or is a new copy returned?+
The original file is never touched. The API returns the encrypted PDF as raw binary bytes in the response body (Content-Type application/pdf). Write the response bytes directly to a new .pdf file. Useful when the unprotected source must remain intact for audit trails.
Can I encrypt PDFs in bulk?+
Each call protects one PDF and the endpoint is stateless. For bulk encryption, loop over files in your script (Python for loop, C# foreach, Node async map) or use a Make, Zapier, Power Automate, or n8n scenario that fires the Protect action per file picked up by a folder watcher.
Does this work as an alternative to SmallPDF, iLovePDF, or Adobe Acrobat password protection?+
Yes. The Protect endpoint provides the same outcome (password-encrypted PDF with permission control) through a REST API. No per-user license, no manual upload, and full automation. The same call from a script handles one document or one thousand.
Is the response binary or Base64?+
The response body is the raw binary PDF (Content-Type application/pdf), not JSON. Write the response bytes straight to a .pdf file: response.content in Python requests, response.body in fetch, await Content.ReadAsByteArrayAsync in C#. The Base64 envelope is only used for input (the docContent field you send in the request), not for the output.
How do I test the API without writing code?+
Open the Protect Document API Tester, paste your API key, upload a PDF, type a password, and pick a pdfPermission flag. The tester shows the request and lets you download the encrypted PDF directly.

Tindakan terkait

Tugas yang sama di platform lain

Dapatkan Bantuan