This issue occurs because the image URL being used is not a direct image file link, but a Salesforce-generated or hosted URL that returns HTML content instead of raw image data. Apsona merge requires a direct image stream and cannot process URLs that execute scripts or return HTML responses.
Salesforce now uses Files (ContentVersion) for storage, which introduces stricter security. As a result, public links from Salesforce Files or external sources (like Google Drive) may display correctly in a browser but do not behave as direct image URLs during a merge, leading to the error: “Not a valid image - content type was text/html; charset=utf-8”.
The recommended approach is to use the ContentVersion Id (starts with 068) instead of a public URL. Create a custom field to store this ID and map it in the merge template. During the merge, Apsona will automatically locate the corresponding file in Salesforce Files and render the image correctly.
To retrieve the required IDs:
SELECT ContentDocumentId, ContentDocument.Title
FROM ContentDocumentLink
WHERE LinkedEntityId = '001XXXXXXXXXXXXXXX'
SELECT Id, Title, ContentDocumentId
FROM ContentVersion
WHERE ContentDocumentId = '069XXXXXXXXXXXX'
AND IsLatest = true
Always use ContentVersion Ids for image rendering in Apsona merges. Public or shareable URLs may not work even if they appear valid in a browser, and content-type errors typically indicate the URL is not a direct image stream.