Convert JPG to PDF

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


2.4 How to convert jpg and jpeg image to PDF using API Rest


URL

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

https://getoutpdf.com/api/convert/image-to-pdf


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 lincenes
    (string, required)
  • imageImage encoded in base64
    (string, required)
  • transparent_colorIf image contains transparency, set color to be applied to transparent pixels
    (string, optional)

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
    "image": "...",             // string, required
    "transparent_color": "..."  // string, optional, default:#ffffff
}

Example

{
    "api_key": "64b5d1054b69e676b9984d8406c5209a6ba78...",
    "image": "JVBERi0xLjQNJeLjz9MNCjYgMCBvYmo8PC9I...",
    "transparent_color": "#ffffff"
}

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"
    ]
}