Replacing Images in PDF files

This operation replaces one or more images in a PDF file, where each image to be replaced must be identified by its PDF object index (this can be obtained with the ExtractImage operation). For each image, the URL for a replacement image must be specified as well. Moreover, replacement images may be inserted to the background layer of the page, using the asBackground option. See the examples below for details.

The resulting PDF is stored in the S3 cloud storage service and its URL is listed in the output. This URL will then be publicly available for one day.


  • Endpoint: POST http://mu3.hp-mu.com/jobs/sync
  • Authorization: BASIC bXVscHA6eGhDdGNxNW9U
  • Accept-type: application/json
  • Content-type: application/json
  • Input schema sample: (for replacing a single image)
{
    "workflow": [
        {
            "task": "ReplaceImage",
            "inputs": {
                "pdf": "http://127.0.0.1:9999/wallart.pdf",
                "originalImgPath": "<p{1}/d{Resources}/d{XObject}/d{Im1}>",
                "substituteImage": "http://127.0.0.1:9999/x.png"
            }
        }
    ]
}
  • Input schema sample: (for replacing several images)
{
    "workflow": [
        {
            "task": "ReplaceImage",
            "inputs": {
                "pdf": "http://127.0.0.1:9999/wallart.pdf",
                "substitutions": [
                    {
                        "originalImgPath": "<p{1}/d{Resources}/d{XObject}/d{Im1}>",
                        "substituteImage": "http://127.0.0.1:9999/x.png"
                    },
                    {
                        "originalImgPath": "<p{1}/d{Resources}/d{XObject}/d{Im2}>",
                        "substituteImage": "http://127.0.0.1:9999/y.png",
                        "asBackground": true
                    }
                ]
            }
        }
    ]
}
  • Output schema sample:
{
    "id": "54f8c4c817d013e858b01471",
    "status": "success",
    "workflow": [
        {
            "task": "ReplaceImage",
            "inputs": {
                "pdf": "http://127.0.0.1:9999/wallart.pdf",
                "substitutions": [
                    {
                        "originalImgPath": "<p{1}/d{Resources}/d{XObject}/d{Im1}>",
                        "substituteImage": "http://127.0.0.1:9999/x.png"
                    },
                    {
                        "originalImgPath": "<p{1}/d{Resources}/d{XObject}/d{Im2}>",
                        "substituteImage": "http://127.0.0.1:9999/y.png",
                        "asBackground": true
                    }
                ]
            },
            "result": {
                "url": "https://mu3.s3.amazonaws.com/1234.pdf"
            }
        }
    ]
}