IRONSOFTWAREHOME
PDFの暗号化と復号化
using IronPdf;
using System;

//Open an Encrypted File, alternatively create a new PDF from Html

var pdf = PdfDocument.FromFile("encrypted.pdf", "password");

//Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;

//Edit file security settings

//The following code makes a PDF read only and will disallow copy & paste and printing
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;

// change or set the document encrpytion password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
Imports IronPdf
Imports System

'Open an Encrypted File, alternatively create a new PDF from Html

Dim pdf = PdfDocument.FromFile("encrypted.pdf", "password")

'Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.Now

'Edit file security settings

'The following code makes a PDF read only and will disallow copy & paste and printing
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights

' change or set the document encrpytion password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")
NuGet Download
Install-Package IronPdf
PDFの暗号化と復号化

PDFの暗号化と復号化

PDFセキュリティはPDFファイルを扱う際の重要な側面であり、IronPDFはPDFセキュリティを真剣に捉えています。 IronPDFを使用すると、カスタムメタデータとセキュリティ設定をPDFに適用してPDFファイルを暗号化および復号化できます。 IronPDFは、128ビット暗号化をサポートしており、(ファイルにアクセスするために必要な正しいパスワードがある場合)以前に暗号化されたファイルを復号化する機能と、既存または新たに作成したPDF文書にパスワード保護を適用する機能を提供します。

IronPDFを使用してPDFファイルを暗号化および復号化するための最初のステップは、新しいPDFファイルを作成するか、ここで行ったように既存のファイルを読み込むことです。 PDFファイルをFromFileメソッドに2つのパラメーターを渡しました。1つ目はPDFのファイルパスで、2つ目は暗号化されたPDFを開くためのパスワードです。

次の行では、暗号化されたPDFのメタデータを編集します。 たとえば、Authorフィールドをカスタム文字列値で編集するために使用されます。 各メタデータフィールドにはMetaDataプロパティ内でカスタマイズが必要な他の項目を指定するのに特に役立ちます。

次の行では、PDF文書から現在のパスワードおよび暗号化をすべて削除します。 この復号化プロセスにより、PDFを暗号化なしで保存したり、新しい暗号化設定を追加するためにクリアしたりすることができます。これは次に行うことです。 settingは変更したい実際の設定に置き換えられます。 たとえば、pdf.SecuritySettings.MakePdfDocumentReadOnlyはPDFを読み取り専用に設定します。 PdfSecuritySettingsクラスは、ユーザーの注釈を禁止することから印刷許可権限を制御することまで、PDFのセキュリティ設定を完全にカスタマイズするための多くのオプションを含んでいます。 このクラスは、適切なPDFセキュリティが確実かつ効率的に扱われることを保証します。

pdf.Passwordは、PDFのパスワードを変更する、または現在のものがない場合に新しいパスワードを設定するために使用されます。 このパスワードは、強力な128ビット暗号化を使用してPDFファイルを暗号化し、不正アクセスから保護します。 メタデータとセキュリティ設定に満足したら、SaveAs()を使用してPDFドキュメントを所望のファイル位置に保存できます。 IronPDFでPDFの権限とパスワードの設定を学ぶ

GitHubで見る

準備はできましたか?

Nuget Downloads 20,389,208バージョン:2026.7リリースされたばかり

Key in blue circle

無料の30日間トライアルキーをすぐに入手してください。

bullet_checkedクレジットカードやアカウントの作成は不要です。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
無料のライブデモを予約する
Booking Badge related to IronPDF Product Demo

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。