DynaPDF.InsertImageFile
-----------------------

The function inserts an image from a file.

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

MBS( "DynaPDF.InsertImageFile"; PDF; FilePath; PosX; PosY; ScaleWidth; ScaleHeight { ; Index } ) 

**MBS**( **"DynaPDF.InsertImageFile";** /\* The function inserts an image from a file. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$FilePath**; /\* The native file path to the image file.e.g. $path \*/   
**$PosX**; /\* The X position (from left of page)e.g. 0 \*/   
**$PosY**; /\* The Y position (from bottom of page)e.g. 0 \*/   
**$ScaleWidth**; /\* The scaled width of the image.e.g. $width \*/   
**$ScaleHeight**; /\* The scaled height of the image.e.g. $height \*/   
**$Index**) /\* Optional; The index of the image for multi image files.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| FilePath | The native file path to the image file. | $path |  |
| PosX | The X position (from left of page) | 0 |  |
| PosY | The Y position (from bottom of page) | 0 |  |
| ScaleWidth | The scaled width of the image. | $width |  |
| ScaleHeight | The scaled height of the image. | $height |  |
| Index | The index of the image for multi image files. | 1 | Optional |

### Result

Returns image handle number or error message.

### Description

The function inserts an image from a file.   
The parameter Index specifies the image index of a multi- page image. The first image index is denoted by 1. If the image file is not a multi-page image, the parameter Index will be ignored. To determine the number of images stored in an image file call the function [DynaPDF.GetImageCount](DynaPDFGetImageCount.md).  
Positions and sizes are in PDF coordinates which normally is 72 dpi.  
  
Please use [DynaPDF.SetCompressionFilter](DynaPDFSetCompressionFilter.md) to define the compression of your images. Use "flate" there for no jpeg compression. Use [DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md) to define JPEG compression quality. also use [DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md) with parameter 0 to embed JPEGs to PDF without recompression. Also you should turn off transparency by key color using [DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md).  
You can use [DynaPDF.SetAlpha](DynaPDFSetAlpha.md) to set fill transparency to affect how images gain extra transparency.  
  
Coordinates in PDF are by default in a 72dpi raster with lower left being 0/0 point. You can query page size by [DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md) and [DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md) functions.  
See also [InsertImageFile](https://www.monkeybreadsoftware.com/DynaPDF-Manual/InsertImage.shtml) function in DynaPDF manual.

### Examples

Set a few options and insert image from file:

 MBS ( "[DynaPDF.SetCompressionFilter](DynaPDFSetCompressionFilter.md)"; $PDF ; "flate" )  
MBS ( "[DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)"; $PDF ; 0 )  
MBS ( "[DynaPDF.SetResolution](DynaPDFSetResolution.md)"; $PDF ; 300 )  
MBS ( "[DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)"; $PDF ; 0 )  
MBS ( "DynaPDF.InsertImageFile"; $PDF ; "C:\\test.jpg"; 72; 72; 300; 200; 1 )  
Insert and reduce qualty to save space:

 MBS ( "[DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md)"; $PDF ; 75 )  
MBS ( "[DynaPDF.SetCompressionFilter](DynaPDFSetCompressionFilter.md)"; $PDF ; "jpeg" )  
MBS ( "[DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)"; $PDF ; 1 )  
MBS ( "[DynaPDF.SetResolution](DynaPDFSetResolution.md)"; $PDF ; 100 )  
MBS ( "[DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)"; $PDF ; 0 )  
MBS ( "DynaPDF.InsertImageFile"; $PDF ; "C:\\test.jpg"; 72; 72; 300; 200; 1 )  
### See also

- [DynaPDF.AppendImagePages](DynaPDFAppendImagePages.md)
- [DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)
- [DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)
- [DynaPDF.InsertImage](DynaPDFInsertImage.md)
- [DynaPDF.InsertMetafile](DynaPDFInsertMetafile.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetAlpha](DynaPDFSetAlpha.md)
- [DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md)
- [DynaPDF.SetResolution](DynaPDFSetResolution.md)
- [DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)

### Release notes

- **Version 7.2**
    - Fixed a bug with [DynaPDF.InsertImageFile](http://www.mbsplugins.eu/DynaPDFInsertImageFile.shtml).

### Example Databases

- [Mac and iOS/PDFKit/Pictures to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/PDFKit/Pictures%20to%20PDF.shtml#10ScriptAnchor_)

### Blog Entries

- [DynaPDF graphics flags](https://www.mbsplugins.de/archive/2023-08-02/DynaPDF_graphics_flags/monkeybreadsoftware_blog_filemaker)
- [Things you can do with DynaPDF](https://www.mbsplugins.de/archive/2021-07-02/Things_you_can_do_with_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.2pr1](https://www.mbsplugins.de/archive/2017-04-03/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 5.0pr10](https://www.mbsplugins.de/archive/2015-02-06/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2021, Seite 26](https://filemaker-magazin.de/neuigkeit/4158-Appetithappen-FMM_202105)

This function checks for a license.

Created 18th August 2014 , last changed 2nd September 2022

  
[DynaPDF.InsertImage](DynaPDFInsertImage.md) - [DynaPDF.InsertMetafile](DynaPDFInsertMetafile.md)

[HTML Version](DynaPDFInsertImageFile.shtml)