Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

DynaPDF.SaveAndSignFileExt

Saves and signs the current PDF.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 11.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.SaveAndSignFileExt"; PDF; PKCS12 Reference { ; ContactInfo; Location; Reason; Signer; FileName; Preview } )   More

Parameters

Parameter Description Example Flags
PDF The PDF reference returned from DynaPDF.New. $pdf
PKCS12 Reference The reference to the PKCS12.
See PKCS12.ReadFromContainer or PKCS12.ReadFromFile to load a PKCS#12 file.
$pkcs12
ContactInfo The contact info. Optional
Location Signers location string $location Optional
Reason Reason string. $reason Optional
Signer Signers name string $signer Optional
FileName The file name to be associated with the container value.
The file name should include pdf file extension.
"hello.pdf" Optional
Preview Whether to include a preview JPEG.
Default is 1 for including one. Pass zero to disable preview.
1 Optional

Result

Returns PDF container, OK or error.

Description

Saves and signs the current PDF.
On success you either get back the PDF as container value (in memory PDF) or it returns OK after writing PDF to file (file based PDF).
The plugin also renders a JPEG for preview and includes it within the container value (with DynaPDF Pro).

Same as DynaPDF.SaveAndSignFile, but the signing is done by MBS plugin itself instead of DynaPDF. You pass the PKCS#12 key and certificate by reference number. This way we can support more keys than DynaPDF directly, e.g. with 2048 or 4096 bits.

See Plugin.SetPreviewSize to control size of preview picture.

If you have an open page, we close it automatically for you before doing the import.

See also SaveAndSignFileExt function in DynaPDF manual.

Examples

Sign a PDF with PKCS#12 key:

# Initialize DynaPDF if needed
If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
    Perform Script [ Specified: From list ; “InitDynaPDF” ; Parameter: ]
End If
# New PDF
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
#
# output to file
Set Variable [ $destPath ; Value: MBS("Folders.UserDesktop") & "/test.pdf" ]
Set Variable [ $r ; Value: MBS("DynaPDF.OpenOutputFile"; $pdf; $destPath) ]
#
# Load PDF from container
Set Variable [ $r ; Value: MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Merge PDFs::InputPDF) ]
Set Variable [ $r ; Value: MBS("DynaPDF.ImportPDFFile"; $pdf; 1) ]
#
# or sign it on saving
Set Variable [ $pkey ; Value: MBS( "PKCS12.ReadFromFile"; "/Users/cs/Desktop/test_cert.pfx"; "123456" ) ]
Set Field [ Merge PDFs::MergeStatus ; MBS("DynaPDF.SaveAndSignFileExt"; $pdf; $pkey; "Hello"; "World"; ""; ""; "Merged.pdf") ]
#
# cleanup
Set Variable [ $r ; Value: MBS( "PKCS12.Release"; $pkey) ]
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]

See also

Release notes

Blog Entries

This function checks for a license.

Created 8th January 2021, last changed 25th September 2024


DynaPDF.SaveAndSignFile - DynaPDF.SaveAndSignFileExt1