Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5    Statistic  

DynaPDF.ReplaceImage

Replaces an image with another image.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
DynaPDF 7.5 Yes Yes Yes Yes Yes

MBS( "DynaPDF.ReplaceImage"; PDF; ImageIndex; Image { ; ImageIndex; Colorspace; ColorSpaceHandle; Flags } )

Parameters

Parameter Description Example value
PDF The PDF reference returned from DynaPDF.New. $pdf
ImageIndex The index of the image to replace.
From 0 to DynaPDF.GetImageCount-1.
$index
Image The new image.
Can be container or native file path.
Images::ImageContainer
ImageIndex Optional
The index of the image.
This is for a multi picture tiff file to pick the image.
Default is 1 for first image.
1
Colorspace Optional
The color space to use.
Can be DeviceRGB, DeviceCMYK, DeviceGray, CalGray, CalRGB, Lab, ICCBased, Pattern, Indexed, Separation, DeviceN or NChannel.
Default is DeviceRGB.
"DeviceRGB"
ColorSpaceHandle Optional
The color space handle.
Can be empty if you want to use device colorspace.
""
Flags Optional
The flags.
Can be number or text with various flags.
Can be set to DeleteAltImages, DeleteMetadata, DeleteOCG and/or DeleteSoftMask.
"DeleteAltImages¶DeleteMetadata"

Result

Returns OK or error.

Description

Replaces an image with another image.
The resolution, aspect ratio, color space and so on can be freely chosen. However, note that this function does not change the output position or size. If the aspect ratio of the new image is different, then it will be stretched or shrunken to fit into the output rectangle.
The parameter CS specifies the destination color space into which the image should be converted or saved, if the image is already defined in that color space. CSHandle must be the handle of that color space if a non-device space is used. The will be ignored for devices spaces.
The function works in the very same way as DynaPDF.InsertImage with the following differences:

Examples

Replace image:

# Initialize DynaPDF if needed
If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
    Perform Script [ “InitDynaPDF” ]
End If
# Start new PDF session
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
# Import pages
Set Variable [ $r ; Value: MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Replace Image::Input PDF) ]
Set Variable [ $r ; Value: MBS("DynaPDF.ImportPDFFile"; $pdf; 1) ]
# Replace Image
Set Variable [ $r ; Value: MBS("DynaPDF.ReplaceImage"; $pdf; 0; Replace Image::New Image) ]
# Save PDF
Set Field [ Replace Image::Output PDF ; MBS("DynaPDF.Save"; $pdf) ]
# Cleanup
Set Variable [ $r ; Value: MBS( "DynaPDF.Release"; $pdf ) ]

See also


DynaPDF.RenderPage   -   DynaPDF.ReplacePattern

Feedback: Report problem or ask question.




Links
MBS FileMaker Plugins