Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
DynaPDF.EnableEncryption
Enables encryption for next save command.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 3.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
The PDF reference returned from DynaPDF.New. | |||
OpenPwd | Open password. | "" | |
OwnerPwd | Owner password. | "Hello" | |
Encryption | Which encryption to use. Can be 40bit, 128bit, 128bitEx, AES128, AES256 or AESRev6. | "AES256" | |
RestrictFlags | What restrictions to apply. See above. | 4+8 | Optional |
Result
Returns OK on success.
Description
Enables encryption for next save command.Available Encryption methods:
ID | Encryption | PDF Version | Acrobat Version |
0 | RC4 40bit | PDF 1.2 | Acrobat 3 or higher |
1 | RC4 128bit | PDF 1.4 | Acrobat 5 or higher |
2 | RC4 128bit improved | PDF 1.5 | Acrobat 6 or higher |
3 | AES 128bit | PDF 1.6 | Acrobat 7 or higher |
4 | AES 256bit | PDF 1.7 | Acrobat 9 or higher |
Available restrictions:
DenyNothing | 0 | Encrypt the file only |
DenyAll | 3900 | Deny anything |
4 | Deny printing | |
Modify | 8 | Deny modification of contents |
CopyObj | 16 | Deny copying of contents |
AddObj | 32 | No commenting |
FillInFormFields | 256 | requires Modify + AddObj |
ExtractObj | 512 | requires Modify |
Assemble | 1024 | requires Modify |
PrintHighRes | 2048 | Disable high res. printing |
ExlMetadata | 4096 | PDF 1.5 Exclude metadata streams |
EmbFilesOnly | 8192 | PDF 1.6 AES Encryption only |
FillInFormFields and later are for 128/256 bit encryption only, so ignored if 40 bit encryption is used.
Please combine those like this: Print and Modify = 4 + 8 = 12.
Please see DynaPDF help on CloseFileEx function for details on which combination of restrictions are possible.
For passwords, please use only ASCII characters to avoid trouble with text encodings.
Requires DynaPDF Lite license. See CloseAndSignFile in the dynapdf help, since that function will be used later by DynaPDF.Save function.
See also EnableEncryption function in DynaPDF manual.
Examples
Don't allow adding content:
MBS( "DynaPDF.EnableEncryption"; $PDF; ""; "secret"; 1; 16 + 32 + 256 + 1024 )
Create AES 256-bit encrypted PDF:
# Initialize DynaPDF if needed
If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
Perform Script [ Specified: From list ; “InitDynaPDF” ; Parameter: ]
End If
# Clear current PDF document
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
# Add page
Set Variable [ $r ; Value: MBS("DynaPDF.AppendPage"; $pdf) ]
# Write some text
Set Variable [ $r ; Value: MBS("DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 12) ]
Set Variable [ $x ; Value: MBS("DynaPDF.GetPageHeight"; $pdf)-100 ]
Set Variable [ $r ; Value: MBS("DynaPDF.SetFillColor"; $pdf; 0; 0; 0) ]
Set Variable [ $r ; Value: MBS("DynaPDF.WriteText"; $pdf; 100; $x; "Some black text") ]
# End page
Set Variable [ $r ; Value: MBS("DynaPDF.EndPage"; $pdf) ]
# Add encryption with AES
Set Variable [ $r ; Value: MBS( "DynaPDF.EnableEncryption"; $PDF; "xxx"; "yyy"; "AES256"; 8+16+32+256+512+1024+2048+4096 ) ]
# Save PDF to put in container later
Set Variable [ $PDFData ; Value: MBS("DynaPDF.Save"; $pdf; "hello.pdf") ]
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]
# Put in Container
Set Field [ Create Text::PDF ; $PDFData ]
See also
- DynaPDF.AppendPage
- DynaPDF.GetPageHeight
- DynaPDF.GetUserRights
- DynaPDF.IsInitialized
- DynaPDF.New
- DynaPDF.Release
- DynaPDF.Save
- DynaPDF.SetFillColor
- DynaPDF.SetFont
- DynaPDF.WriteText
Blog Entries
- Unlocking the Power of PDFs in FileMaker with DynaPDF and the MBS FileMaker Plugin
- MBS Filemaker Plugin, version 3.4pr2
This function checks for a license.
Created 18th August 2014, last changed 28th May 2024