DynaPDF.SaveAndSignFileWinCryptDialog
-------------------------------------

Saves and signs the current PDF.

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

MBS( "DynaPDF.SaveAndSignFileWinCryptDialog"; PDF { ; StoreName; ContactInfo; Location; Reason; FileName; Preview; DetachedSignature; CertificateName } ) 

**MBS**( **"DynaPDF.SaveAndSignFileWinCryptDialog";** /\* Saves and signs the current PDF. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$StoreName**; /\* Optional; The name of the certificate store. \*/   
**$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 \*/   
**$CertificateName**) /\* Optional; The name of the certificate to find.  
If set, we skip the dialog and look for the given certificate (subject name). \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| StoreName | The name of the certificate store. |  | 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**. |
| CertificateName | The name of the certificate to find.   If set, we skip the dialog and look for the given certificate (subject name). |  | Optional      Added in version **14.2**. |

### Result

Returns 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).  
  
On Windows you can use WinCrypt with [DynaPDF.SaveAndSignFileWinCrypt](DynaPDFSaveAndSignFileWinCrypt.md) function and optionally use dialog to pick the certificate with DynaPDF.SaveAndSignFileWinCryptDialog from the certificate store.  
Use [DynaPDF.SaveAndSignFile](DynaPDFSaveAndSignFile.md) for cross platform signing.  
  
See [Plugin.SetPreviewSize](PluginSetPreviewSize.md) to control size of preview picture.  
### Examples

Save and sign a PDF after you assembled it:

 Set Variable \[ $PDFData ; Value: MBS ("DynaPDF.SaveAndSignFileWinCryptDialog"; $pdf ; ""; "MY") \]   
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.SaveAndSignFileWinCrypt](DynaPDFSaveAndSignFileWinCrypt.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.

### Example Databases

- [DynaPDF/Merge PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Merge%20PDFs.shtml#13ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.2pr1](https://www.mbsplugins.de/archive/2024-04-02/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [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 19th March 2024

  
[DynaPDF.SaveAndSignFileWinCrypt](DynaPDFSaveAndSignFileWinCrypt.md) - [DynaPDF.SaveGraphicState](DynaPDFSaveGraphicState.md)

[HTML Version](DynaPDFSaveAndSignFileWinCryptDialog.shtml)