DynaPDF.SaveAndSignFileWinCrypt
-------------------------------

Saves and signs the current PDF with dialog to pick certificate.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [10.1](newinversion101.md) | ❌ No | ✅ Yes | ❌ No | ✅ Yes, on Windows | ❌ No |

MBS( "DynaPDF.SaveAndSignFileWinCrypt"; PDF; SignatureContainer { ; Password; ContactInfo; Location; Reason; FileName; Preview; DetachedSignature } ) 

**MBS**( **"DynaPDF.SaveAndSignFileWinCrypt";** /\* Saves and signs the current PDF with dialog to pick certificate. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$SignatureContainer**; /\* The container with the PKCS#12 file. \*/   
**$Password**; /\* Optional; The password to read the signature.  
Leave empty if not encrypted.e.g. "123456" \*/   
**$ContactInfo**; /\* Optional; Optional contact info. \*/   
**$Location**; /\* Optional; Optional signers location string \*/   
**$Reason**; /\* Optional; Optional reason string. \*/   
**$FileName**; /\* Optional; Optionally the file name to be associated with the container value.  
The file name should include pdf file extension.e.g. "hello.pdf" \*/   
**$Preview**; /\* Optional; Optional, whether to include a preview JPEG.   
Default is 1 for including one. Pass zero to disable preview.e.g. 1 \*/   
**$DetachedSignature**) /\* Optional; Whether to use a detached signature.  
Pass 1 for detached signature vs. 0 for SHA1 signature.  
Default is 0.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| SignatureContainer | The container with the PKCS#12 file. |  |  |
| Password | The password to read the signature.   Leave empty if not encrypted. | "123456" | Optional |
| ContactInfo | Optional contact info. |  | Optional |
| Location | Optional signers location string | $location | Optional |
| Reason | Optional reason string. | $reason | Optional |
| FileName | Optionally the file name to be associated with the container value.   The file name should include pdf file extension. | "hello.pdf" | Optional |
| Preview | Optional, whether to include a preview JPEG.    Default is 1 for including one. Pass zero to disable preview. | 1 | Optional |
| DetachedSignature | Whether to use a detached signature.   Pass 1 for detached signature vs. 0 for SHA1 signature.   Default is 0. | 0 | Optional      Added in version **11.2**. |

### Result

Returns OK or error.

### Description

Saves and signs the current PDF with dialog to pick certificate.  
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).  
  
On Windows you can use WinCrypt with DynaPDF.SaveAndSignFileWinCrypt function and optionally use dialog to pick the certificate with [DynaPDF.SaveAndSignFileWinCryptDialog](DynaPDFSaveAndSignFileWinCryptDialog.md) from the certificate store.  
Use [DynaPDF.SaveAndSignFile](DynaPDFSaveAndSignFile.md) for cross platform signing.  
  
See [Plugin.SetPreviewSize](PluginSetPreviewSize.md) to control size of preview picture.  
  
If you have an open page, we close it automatically for you before doing the import.  
### Examples

Save and sign a PDF after you assembled it:

 Set Variable \[ $PDFData ; Value: MBS ("DynaPDF.SaveAndSignFileWinCrypt"; $pdf ; "C:\\Users\\Christian\\Desktop\\test\_cert.pfx"; "123456") \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]   
\# Put in Container   
Set Field \[ Create Text::PDF ; $PDFData \]  
### See also

- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.SaveAndSignFile](DynaPDFSaveAndSignFile.md)
- [DynaPDF.SaveAndSignFileExt](DynaPDFSaveAndSignFileExt.md)
- [DynaPDF.SaveAndSignFileExt1](DynaPDFSaveAndSignFileExt1.md)
- [DynaPDF.SaveAndSignFileExt2](DynaPDFSaveAndSignFileExt2.md)
- [DynaPDF.SaveAndSignFileWinCryptDialog](DynaPDFSaveAndSignFileWinCryptDialog.md)
- [Plugin.SetPreviewSize](PluginSetPreviewSize.md)

### Release notes

- **Version 14.2**
    - Added CertificateName parameter to [DynaPDF.SaveAndSignFileWinCryptDialog](https://www.mbsplugins.eu/DynaPDFSaveAndSignFileWinCryptDialog.shtml) function to skip dialog and pick certificate by name.
- **Version 10.1**
    - Added [DynaPDF.SaveAndSignFileWinCrypt](https://www.mbsplugins.eu/DynaPDFSaveAndSignFileWinCrypt.shtml) and [DynaPDF.SaveAndSignFileWinCryptDialog](https://www.mbsplugins.eu/DynaPDFSaveAndSignFileWinCryptDialog.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 10.1pr2](https://www.mbsplugins.de/archive/2020-02-03/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 31st January 2020 , last changed 25th September 2024

  
[DynaPDF.SaveAndSignFileExt2](DynaPDFSaveAndSignFileExt2.md) - [DynaPDF.SaveAndSignFileWinCryptDialog](DynaPDFSaveAndSignFileWinCryptDialog.md)

[HTML Version](DynaPDFSaveAndSignFileWinCrypt.shtml)