DynaPDF.AssociateEmbFile
------------------------

Associates an embedded file with a PDF object.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [6.0](newinversion60.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.AssociateEmbFile"; PDF; DestObject; DestHandle; Relationship; EmbFile ) 

**MBS**( **"DynaPDF.AssociateEmbFile";** /\* Associates an embedded file with a PDF object. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$DestObject**; /\* The destination object type.  
Can be Annotation, Catalog, Field, Image, Page or Template.e.g. "Annotation" \*/   
**$DestHandle**; /\* The destination object handle or -1.e.g. -1 \*/   
**$Relationship**; /\* The relationship for the object to its parent.  
Can be Associated, Data, Source, Supplement or Alternative.  
The value Alternative must be used for ZUGFeRD compatible invoices.e.g. "Alternative" \*/   
**$EmbFile**) /\* Handle of an embedded file. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| DestObject | The destination object type.   Can be Annotation, Catalog, Field, Image, Page or Template. | "Annotation" |
| DestHandle | The destination object handle or -1. | -1 |
| Relationship | The relationship for the object to its parent.   Can be Associated, Data, Source, Supplement or Alternative.   The value Alternative must be used for ZUGFeRD compatible invoices. | "Alternative" |
| EmbFile | Handle of an embedded file. |  |

### Result

Returns OK or error.

### Description

Associates an embedded file with a PDF object.   
The parameter DestHandle must be a valid handle of a PDF object. If destination object type is a page, then the page number must be used as handle. The first page is denoted by one. If the destination object is the documents catalog then the parameter DestHandle is ignored. Set the parameter to zero or -1 in this case.   
The parameter EmbFile must be a valid handle of an embedded file. See [DynaPDF.AttachFile](DynaPDFAttachFile.md) or AttachFile for further information.   
Associated files are supported since PDF 2.0 and in PDF/A 3 files. In PDF/A 3 files all embedded files must be associated with a PDF object.   
See also [AssociateEmbFile](https://www.monkeybreadsoftware.com/DynaPDF-Manual/AssociateEmbFile.shtml) function in DynaPDF manual.

### Examples

Add ZUGFeRD invoice xml file:

 Set Variable \[$FileHandle ; Value:MBS ("[DynaPDF.AttachFileText](DynaPDFAttachFileText.md)"; $pdf ; ZUGFeRD Invoice::Invoice XML; "UTF-8"; "ZUGFeRD-invoice.xml"; "Invoice as XML")\]  
Set Variable \[$r ; Value:MBS ("DynaPDF.AssociateEmbFile"; $pdf ; "Catalog"; -1; "Alternative"; $FileHandle )\]  
### See also

- [DynaPDF.AttachFile](DynaPDFAttachFile.md)
- [DynaPDF.AttachFileText](DynaPDFAttachFileText.md)
- [DynaPDF.New](DynaPDFNew.md)

### Example Databases

- [DynaPDF/ZUGFeRD and Facture-X/ZUGFeRD Invoice](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/ZUGFeRD%20and%20Facture-X/ZUGFeRD%20Invoice.shtml#2ScriptAnchor_)
- [DynaPDF/ZUGFeRD and Facture-X/ZUGFeRD Rechnung erstellen](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/ZUGFeRD%20and%20Facture-X/ZUGFeRD%20Rechnung%20erstellen.shtml#9ScriptAnchor_)

### Blog Entries

- [FileMaker with ZUGFeRD 2.0 and Factur-X](https://www.mbsplugins.de/archive/2019-06-14/FileMaker_with_ZUGFeRD_20_and_/monkeybreadsoftware_blog_filemaker)
- [Creating PDF/A in FileMaker with ZUGFeRD standard](https://www.mbsplugins.de/archive/2018-04-05/Creating_PDFA_in_FileMaker_wit/monkeybreadsoftware_blog_filemaker)
- [Creating PDF/A in FileMaker with ZUGFeRD standard](https://www.mbsplugins.de/archive/2017-03-07/Creating_PDFA_in_FileMaker_wit/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.5pr3](https://www.mbsplugins.de/archive/2015-12-19/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2018, Seite 24](https://filemaker-magazin.de/neuigkeit/3981-Appetithappen-FMM_201801)

This function checks for a license.

Created 15th December 2015 , last changed 16th August 2016

  
[DynaPDF.ApplyShading](DynaPDFApplyShading.md) - [DynaPDF.AttachFile](DynaPDFAttachFile.md)

[HTML Version](DynaPDFAssociateEmbFile.shtml)