Skip to main content

Replace Text with Image

ImageReplace Text with Image

The Replace Text with Image API replaces specified text in a PDF with an image. You send the PDF (docContent, docName), replaceText, imageContent (Base64), and optionally pageSequence (e.g. "all", "1", "2-5"), imageHeight, imageWidth, and async. The API returns the PDF with text replaced by the image. Use the tester below to try it; more details are in the sections that follow.

Try the Replace Text with Image API

Quick reference

Endpoint: POST /api/v2/ReplaceTextWithImage · Required: api-key, docContent, docName, replaceText, imageContent

Try it live

Use the form below to send your API key, PDF (Base64), text to replace, replacement image (Base64), and optional page selection. The response is the PDF with text replaced by the image. No code required—fill the fields and click Send request.

Loading API Tester...

Overview, parameters, and use cases

What is Replace Text with Image?

This endpoint replaces specified text in a PDF with an image. You provide the PDF (Base64), docName, replaceText (the text to find), imageContent (replacement image, Base64), and optionally pageSequence ("all", "1", "1,3,5", "2-5", "2-"), imageHeight, imageWidth. The API returns the PDF with matching text replaced by the image on the selected pages.

Key features

  • Text match – Replaces occurrences of replaceText with the image.
  • Page selectionpageSequence: "all", "1", "1,3,5", "2-5", "2-".
  • Image size – Optional imageHeight and imageWidth in points.
Best for

Use when you need to swap placeholders or text with logos, stamps, or graphics in a PDF. For adding an image without replacing text use Add Image Stamp to PDF.

Prerequisites

Before using this endpoint, make sure you have:

  • A valid PDF4me API key (Get your API Key)
  • A PDF file in Base64 format
  • An image file (JPG, PNG, GIF, BMP, TIFF) in Base64 format

Response Format

The API returns a PDF file with the specified text replaced by the image on the selected pages.

Get Help