DynaPDF.Table.SetCellImage
--------------------------

Inserts an image horizontally and vertically aligned as specified.

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

MBS( "DynaPDF.Table.SetCellImage"; Table; Row; Col; ForeGround; HAlign; VAlign; Width; Height; ImagePath { ; Index } ) 

**MBS**( **"DynaPDF.Table.SetCellImage";** /\* Inserts an image horizontally and vertically aligned as specified. \*/  
**$Table**; /\* The identifier for the table. \*/   
**$Row**; /\* The row number. Range from 0 to [DynaPDF.Table.GetNumRows](DynaPDFTableGetNumRows.md)-1. Pass -1 for all rows.e.g. 0 \*/   
**$Col**; /\* The column number. Range from 0 to [DynaPDF.Table.GetNumCols](DynaPDFTableGetNumCols.md)-1. Pass -1 for all columns.e.g. 0 \*/   
**$ForeGround**; /\* If 1, the cell will be expanded if necessary.e.g. 1 \*/   
**$HAlign**; /\* The horizontal alignment. Can be left, center or right.e.g. "center" \*/   
**$VAlign**; /\* The vertical alignment. Can be bottom, center or top.e.g. "center" \*/   
**$Width**; /\* The image width. Must be greater or equal zero.e.g. 50 \*/   
**$Height**; /\* The image height. Must be greater or equal zero.e.g. 50 \*/   
**$ImagePath**; /\* The native path to the image file.e.g. $Path \*/   
**$Index**) /\* Optional; The index of the image in the file.e.g. 1 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Table | The identifier for the table. | $Table |  |
| Row | The row number. Range from 0 to [DynaPDF.Table.GetNumRows](DynaPDFTableGetNumRows.md)-1. Pass -1 for all rows. | 0 |  |
| Col | The column number. Range from 0 to [DynaPDF.Table.GetNumCols](DynaPDFTableGetNumCols.md)-1. Pass -1 for all columns. | 0 |  |
| ForeGround | If 1, the cell will be expanded if necessary. | 1 |  |
| HAlign | The horizontal alignment. Can be left, center or right. | "center" |  |
| VAlign | The vertical alignment. Can be bottom, center or top. | "center" |  |
| Width | The image width. Must be greater or equal zero. | 50 |  |
| Height | The image height. Must be greater or equal zero. | 50 |  |
| ImagePath | The native path to the image file. | $Path |  |
| Index | The index of the image in the file. | 1 | Optional |

### Result

Returns OK or error.

### Description

Inserts an image horizontally and vertically aligned as specified.   
The image will be loaded when the table is drawn. Therefore, please use an absolute path.  
If the image is inserted as a background object, then it will be clipped if it does not fit into the cell boundary. A cell can contain a background and a foreground object.  
An image can also be added to the table as background object.  
Foreground objects have a strong width and height. That means the cell will be expanded if necessary.  
Image formats which support no transparency are inserted opaque. Transparent GIF images are inserted transparent and alpha channels in images will be considered. Images should normally be inserted in the native image color space. To achieve this, set the flag UseImageCS with [DynaPDF.Table.SetFlags](DynaPDFTableSetFlags.md).  
Images can be scaled into the cell as follows:  
- Width = 0 and Height = 0 -&gt; The image is scaled to the cell width or height depending on the cell orientation. The aspect ratio will be preserved. If the flag tfScaleToRect is set, the image is scaled so that both sides fit into the cell width and height. The row height must be greater zero to achieve a meaningful result.
- Width &gt; 0 and Height = 0 or Width = 0 and Height &gt; 0 -&gt; The image is scaled to the given width or height. The aspect ratio will be preserved. If the flag tfScaleToRect is set, the image is scaled so that both sides fit into the given width or height and into cell width or height depending on which side is missing. If the parameter Height and the row height are zero then the flag tfScaleToRect has no effect.
- Width &gt; 0 and Height &gt; 0 -&gt; The image is scaled to the given width and height. The aspect ratio is not preserved. If the flag tfScaleToRect is set, the image is scaled so that both sides fit into the given width and height and the aspect ratio is preserved.

The parameters Width and Height are not exchanged if the cell uses a landscape orientation.  
  
This function needs a native path. Please use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) function in order to convert a FileMaker style path to a native path.  
### Examples

Add row and insert picture:

 Set Variable \[$subrow ; Value:MBS ("[DynaPDF.Table.AddRow](DynaPDFTableAddRow.md)"; $subtable )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.Table.SetCellImageEx](DynaPDFTableSetCellImageEx.md)"; $subtable ; $subrow ; 0; 1; "left"; "top"; 200; 0; Images::Image )\]  
### See also

- [DynaPDF.Table.AddRow](DynaPDFTableAddRow.md)
- [DynaPDF.Table.GetNumCols](DynaPDFTableGetNumCols.md)
- [DynaPDF.Table.GetNumRows](DynaPDFTableGetNumRows.md)
- [DynaPDF.Table.SetCellPadding](DynaPDFTableSetCellPadding.md)
- [DynaPDF.Table.SetCellSpacing](DynaPDFTableSetCellSpacing.md)
- [DynaPDF.Table.SetCellTable](DynaPDFTableSetCellTable.md)
- [DynaPDF.Table.SetCellTemplate](DynaPDFTableSetCellTemplate.md)
- [DynaPDF.Table.SetCellText](DynaPDFTableSetCellText.md)
- [DynaPDF.Table.SetColWidth](DynaPDFTableSetColWidth.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 12.1**
    - Fixed problem with [DynaPDF.Table.SetCellImageEx](https://www.mbsplugins.eu/DynaPDFTableSetCellImageEx.shtml) not passing JPEG preview for WMF image on MacOS.

This function checks for a license.

Created 18th August 2014 , last changed 18th October 2016

  
[DynaPDF.Table.SetCellAction](DynaPDFTableSetCellAction.md) - [DynaPDF.Table.SetCellImageEx](DynaPDFTableSetCellImageEx.md)

[HTML Version](DynaPDFTableSetCellImage.shtml)