Sign PDF with image

If you find any problem with API, please make an issue at GitHub


3.1 How to sign a PDF document with a sign image using API Rest


URL

To sign a PDF width an image using our API Rest is necessary to perform a POST call to the following URL (ENDPOINT):

https://getoutpdf.com/api/sign/pdf-with-image


GET Parameters

Our Rest API does not have operations via GET parameters


POST Parameters

  • api_keyApi key generated for your license. You can see your api key
    (string, required)
  • pdf_inSource PDF encoded in base64
    (string, required)
  • imageSource image encoded in base64
    (string, required)
  • sign_xHorizontal position (X coordinate) of the image in millimeters (mm) - The value "0" indicates that the image will be attached to the left edge - The value "-1" indicates that the image will be attached to the right edge
    (numeric, optional, default: -1, values: -1|>0)
  • sign_yHorizontal position (Y coordinate) of the image in millimeters (mm) - The value "0" indicates that the image will be attached to the top edge - The value "-1" indicates that the image will be attached to the bottom edge
    (numeric, optional, default: -1, values: -1|>0)
  • sign_widthImage width in millimeters (mm) - The value "0" calculates width automatically
    (numeric, optional, default: 0, min: 0)
  • sign_heightImage height in millimeters (mm) - The value "0" calculates height automatically
    (numeric, optional, default: 0, min: 0)
  • sign_pagesIt indicates that pages will be signed
    (string, optional, default: all, values: first | last | all)

Supported image file formats: jpg, jpeg, exif, tiff, gif, bmp, png, ppm, pgm, pbm, pnm


You can make a POST call using the HTML Header application/x-www-form-urlencoded, with the parameters described above.

Or you can send parameters via the JSON format, using the HTML Header application/json:

{
    "api_key" : "...",          // string, required
    "pdf_in" : "...",           // string, required
    "image" : "...",            // string, required
    "sign_x" : "...",           // numeric, optional, default: -1, values: -1|>0
    "sign_y" : "...",           // numeric, optional, default: -1, values: -1|>0
    "sign_width" : "...",       // numeric, optional, default: 0, min: 0
    "sign_height" : "...",      // numeric, optional, default: 0, min: 0
    "sign_pages" : "..."        // string, optional, default: all, values: first|last|all
}

Example

{
    "api_key" : "64b5d1054b69e676b9984d8406c5209a6ba78...",
    "pdf_in" : "JVBERi0xLjQNJeLjz9MNCjYgMCBvYmo8PC9I...",
    "image" : "JVBERi0xLjQNJeLjz9MNCjYgMCBvYmo8PC9I...",
    "sign_x" : -1,
    "sign_y" : 2.45,
    "sign_width" : 24.45,
    "sign_height" : 24.45,
    "sign_pages" : "all"
}

Response

If the operation is successful the response is a JSON with the following structure:

{
    "api_key": "...",       // string - Api key used for your license
    "pdf_base64": "...",    // string - PDF file encoded in base64
    "tokens_used": "...",   // integer - Tokens used in operation
    "tokens_left": "..."    // integer - Tokens left
}

Errors

If an error in sending parameters occurs, the response is a JSON with the following structure:

{
    "errors": {
        "param1": [     // string - Parameter name that generated the error
            "message"   // string - Error description
        ],
        "param2": [
            "message"
        ],
        ...
        "paramN": [
            "message"
        ]
    }
}

If a operation error occurs, the answer will be a JSON with the following structure:

{
    "errors": [
        "message1",
        "message2",
        ...
        "messageN"
    ]
}