パスワード、セキュリティ、およびメタデータ
IronPDFは開発者に強力なPDFセキュリティオプションを提供し、PDFメタデータ、パスワード、権限などのカスタマイズと設定をサポートします。 IronPDFのパスワード、セキュリティ、およびメタデータオプションを使用すると、PDFドキュメントのニーズに合わせたカスタムの権限とセキュリティレベルを作成できます。 これは、SecuritySettingsおよびMetaDataクラスなどのクラスを使用して行われます。 いくつかのオプションには、PDFドキュメントを印刷不可能に制限すること、読み取り専用に設定すること、128ビット暗号化、およびPDFドキュメントのパスワード保護が含まれます。
カスタムメタデータの設定は、MetaDataクラスを実装してさまざまなPDFメタデータオプションにアクセスし、カスタマイズした値でそれらを設定することによって機能します。 これには、著者、キーワード、変更データなどを変更することが含まれます。 カスタムセキュリティ設定を行うには、カスタムユーザーおよびオーナーパスワードの設定、印刷権限の設定、読み取り専用モードの設定などがあります。
PDFのパスワード、メタデータ、セキュリティを設定する5つのステップ
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");.System.Collections.Generic.List<string> metadatakeys = pdf.MetaData.Keys;.var metadatakeys = pdf.MetaData.Keys;.- <コード>pdf.MetaData.Author = "Satoshi Nakamoto";コード>
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");。
PDFドキュメントのセキュリティをカスタマイズするために、まず既存のPDFをロードするか新しいものを作成する必要があります。 ここでは、パスワード保護された既存のPDFドキュメントをロードし、PDFドキュメントを開くために必要なパスワードを入力しました。 Once the PDF is loaded, we then use pdf.MetaData.Keys to get the PDF's current metadata. To remove existing PDF metadata values, use the RemoveMetaDataKey method. To begin setting new metadata values, use pdf.MetaData.metadataField (e.g., pdf.MetaData.Keywords), and then just assign the new value to it. Metadata fields such as Title and Keywords take string values, whereas the ModifiedData field takes datetime values.
Next, we have set new security settings using the SecuritySettings class. ご覧の通り、ここで設定できるさまざまな設定があります。 これにより、作業するPDFドキュメントごとに権限とセキュリティレベルを完全に制御できます。 To access these settings, you just need to make sure you use pdf.SecuritySettings, followed by the setting you want to adjust. For example, the MakePdfDocumentReadOnly method sets the PDF document to be read-only, encrypting the content at 128-bit. Other options for SecuritySettings include:
AllowUserAnnotations: Controls whether or not users can annotate the PDF.AllowUserPrinting: Controls printing permissions for the document.AllowUserFormData: Sets the permissions for whether users can fill-in forms.OwnerPassword: Sets the owner password for the PDF, which is used to disable or enable the other security settings.UserPassword: Sets the user password for the PDF, which must be entered in order to open or print the document.
カスタムメタデータ、パスワード、およびセキュリティ設定をPDFドキュメントに設定したら、pdf.SaveAsメソッドを使用してPDFを指定された場所に保存します。





