PDFKit.SetPDFAttribute
----------------------

Sets a PDF attribute.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [PDFKit](component_PDFKit.md) | [2.3](newinversion23.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "PDFKit.SetPDFAttribute"; PDF; Key; Value ) 

**MBS**( **"PDFKit.SetPDFAttribute";** /\* Sets a PDF attribute. \*/  
**$PDF**; /\* A PDF reference from [PDFKit.Open](PDFKitOpen.md) or other functions.e.g. $ref \*/   
**$Key**; /\* Which information to set. This can be one of the following: Title, Subject, Author, Creator or Keywords.e.g. "Title" \*/   
**$Value**) /\* The new value for this key. Either a text for text value or a timestamp for a date.e.g. "new value" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | A PDF reference from [PDFKit.Open](PDFKitOpen.md) or other functions. | $ref |
| Key | Which information to set. This can be one of the following: Title, Subject, Author, Creator or Keywords. | "Title" |
| Value | The new value for this key. Either a text for text value or a timestamp for a date. | "new value" |

### Result

Returns "OK" on success or an error message.

### Description

Sets a PDF attribute.   
While you can pass here a container value or an URL to a PDF file, you should really pass a reference value. Because once you changed the PDF attribute, you want to save the PDF with a call to PDFKit.GetDocument.  
New keys in v5.4: OwnerPassword, UserPassword, EncryptionKeyLength, AllowsPrinting and AllowsCopying.  
  
| Key | Description |
|---|---|
| Title | The document's title. Optional; if present, the value of this key must be a text. |
| Author | The name of the person who created this document. Optional; if present, the value of this key must be a text. |
| Subject | The subject of a document. Optional; if present, the value of this key must be a text. |
| Keywords | The keywords for this document. This key is optional. Must be the keywords with comma separated. |
| Creator | The name of the application that created the original data used to create this document. Optional; if present, the value of this key must be a text. |
| OwnerPassword | The "owner password" of the PDF document. If this key is specified, the document will be encrypted using the value as the owner password; otherwise, the document will not be encrypted. The value of this key must be a text which can be represented in ASCII encoding; only the first 32 bytes will be used for the password. There is no default value for this key. If the value of this key cannot be represented in ASCII, the document will not be created and the creation function will fail. |
| UserPassword | The "user password" of the PDF document. If the document is encrypted, then the value of this key will be the user password for the document; if unspecified, the user password will be the empty string. The value of this key must be a text which can be represented in ASCII encoding; only the first 32 bytes will be used for the password. If the value of this key cannot be represented in ASCII, the document will not be created and the creation function will fail. |
| EncryptionKeyLength | Specifies the encryption key length in bits; see Table 3.18 "Entries common to all encryption dictionaries", PDF Reference: Adobe PDF version 1.5 (4th ed.) for more info. Optional; if present, the value of this key must be a number with value which is a multiple of 8 between 40 and 128, inclusive. If this key is absent or invalid, the encryption key length defaults to 40 bits. |
| AllowsPrinting | Used to specify whether the document allows printing when unlocked with the user password. The value of this key must be a boolean. The default value of this key is 1 (true). |
| AllowsCopying | Used to specify whether the document allows copying when unlocked with the user password. The value of this key must be a boolean. The default value of this key is 1 (true). |
| CreationDate | The creation date of PDF. |
| ModificationDate | The modification date of PDF. |

  
If you need more control about encryption, restrictions or metadata, you may want to checkout our [DynaPDF](component_DynaPDF.md) functions in the plugin.  
  
Your changes are only done in memory, so please remember to write modified pdf back to disk, e.g. by using [PDFKit.WriteToPath](PDFKitWriteToPath.md). Or use [PDFKit.GetPDFDocument](PDFKitGetPDFDocument.md) to get a PDF for storing in a container.  
### Examples

Set title to a PDF:

 MBS ("PDFKit.SetPDFAttribute"; $ref ; "title"; "The new title for this PDF file." )  
Rotate page and set title:

 # open PDF from container   
Set Variable \[$ref ; Value:MBS ("[PDFKit.OpenContainer](PDFKitOpenContainer.md)"; combine pdf::result )\]  
\# Set title for PDF   
Set Variable \[$result ; Value:MBS ("PDFKit.SetPDFAttribute"; $ref ; "Title"; combine pdf::title )\]  
\# Rotate first page by 90°   
Set Variable \[$result ; Value:MBS ("[PDFKit.SetPDFPageRotation](PDFKitSetPDFPageRotation.md)"; $ref ; 0; 90)\]  
\# save document to container   
Set Field \[combine pdf::result ; MBS ("[PDFKit.GetPDFDocument](PDFKitGetPDFDocument.md)"; $ref ; "result.pdf")\]  
\# free memory   
Set Variable \[$result ; Value:MBS ("[PDFKit.Release](PDFKitRelease.md)"; $ref )\]  
Create PDF with passwords:

 Set Variable \[$ref ; Value:MBS ("[PDFKit.OpenContainer](PDFKitOpenContainer.md)"; combine pdf::test1 )\]  
Set Variable \[$r ; Value:MBS ("PDFKit.SetPDFAttribute"; $ref ; "OwnerPassword"; "owner")\]  
Set Variable \[$r ; Value:MBS ("PDFKit.SetPDFAttribute"; $ref ; "UserPassword"; "test")\]  
Set Variable \[$r ; Value:MBS ("PDFKit.SetPDFAttribute"; $ref ; "EncryptionKeyLength"; 128)\]  
Set Variable \[$r ; Value:MBS ("PDFKit.SetPDFAttribute"; $ref ; "AllowsPrinting"; 0)\]  
Set Variable \[$r ; Value:MBS ("PDFKit.SetPDFAttribute"; $ref ; "AllowsCopying"; 0)\]  
Set Field \[combine pdf::result ; MBS ("[PDFKit.GetPDFDocument](PDFKitGetPDFDocument.md)"; $ref ; "result.pdf")\]  
Set Variable \[$result ; Value:MBS ("[PDFKit.Release](PDFKitRelease.md)"; $ref )\]  
### See also

- [PDFKit.GetPDFAttribute](PDFKitGetPDFAttribute.md)
- [PDFKit.GetPDFDocument](PDFKitGetPDFDocument.md)
- [PDFKit.Open](PDFKitOpen.md)
- [PDFKit.OpenContainer](PDFKitOpenContainer.md)
- [PDFKit.Release](PDFKitRelease.md)
- [PDFKit.SetPDFPageRotation](PDFKitSetPDFPageRotation.md)
- [PDFKit.WriteToPath](PDFKitWriteToPath.md)

### Example Databases

- [Mac and iOS/PDFKit/Combine PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/Combine%20PDFs.shtml#3ScriptAnchor_)
- [Mac and iOS/PDFKit/Encrypt PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/Encrypt%20PDF.shtml#3ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 5.4pr2](https://www.mbsplugins.de/archive/2015-10-15/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2026, Seite 28](https://filemaker-magazin.de/neuigkeit/4312-Die-neue-Ausgabe-FMM_202601-steht-online)

This function checks for a license.

Created 18th August 2014 , last changed 5th December 2022

  
[PDFKit.SetIgnoreCombineErrors](PDFKitSetIgnoreCombineErrors.md) - [PDFKit.SetPDFPageDisplayAnnotation](PDFKitSetPDFPageDisplayAnnotation.md)

[HTML Version](PDFKitSetPDFAttribute.shtml)