WEB to JPG Rest API.

The API for converting Web Pages to JPG files.

Available converters

API Request

Parameter Description Value
Secret

Optional

String

Authentication secret (if omitted, token must be provided)

Secret
Token

Optional

String

Authentication token (if omitted, secret must be provided)

Token
Parameter Description Value
FileName

Optional

String

File name (without extension) of the converted file.

FileName
Parameter Description Value
Timeout

Optional

Integer

Conversion timeout in seconds.

Default: 300

Values: 10 .. 1200

Timeout
StoreFile

Optional

Bool

Store converted file on server.

Default: False

StoreFile
Url

Required

String

URI of a web page to convert. Must start with http:// or https://. Several URI of web pages merged with %20 (space) symbol can be passed to create one PDF. For example if http://www.google.com%20http://www.nytimes.com URI will be passed the two web pages will be merged into one PDF. If URI has special characters like ? or & they must be encoded. Also a HTML code can be submitted for conversion using this parameter.

Url
ConversionDelay

Optional

Integer

Delay in seconds before page load and PDF creation. Sometimes usefull to let web page to load in full.

Default: 0

Values: 0 .. 30

ConversionDelay
Parameter Description Value
AuthUsername

Optional

String

HTTP authentication username. Could be used if conversion web page is protected with HTTP authentication.

AuthUsername
AuthPassword

Optional

String

HTTP authentication password. Could be used if conversion web page is protected with HTTP authentication.

AuthPassword
Parameter Description Value
AdBlock

Optional

Bool

Block ads in converting page.

Default: False

AdBlock
Zoom

Optional

Float

Set the default zoom level of webpages.

Default: 1

Values: 0.001 .. 10.0

Zoom
Parameter Description Value
ImageWidth

Optional

Integer

Image width in pixels.

Default: 1280

Values: 1 .. 16384

ImageWidth
ImageHeight

Optional

Integer

Image height in pixels.

Values: 1 .. 16384

ImageHeight
CropX

Optional

Integer

Screenshot crop X offset.

Default: 0

Values: 0 .. 16384

CropX
CropY

Optional

Integer

Screenshot crop Y offset.

Default: 0

Values: 0 .. 16384

CropY
CropWidth

Optional

Integer

Screenshot crop width.

Values: 1 .. 16384

CropWidth
CropHeight

Optional

Integer

Screenshot crop height.

Values: 1 .. 16384

CropHeight
Parameter Description Value
JpgQuality

Optional

Integer

Set JPG quality.

Default: 75

Values: 1 .. 100

JpgQuality

Snippets are autogenerated according to converter parameter choices above. Please select file in "File" or "Files" parameter before using code snippets.

Media Types

Authentication parameter (secret or token) always must be provided as a query parameter.

Request

  • application/json - JSON scheme also can be built in Code Snippets section. File data must be encoded with Base64 encoding, provided as URL or uploaded File ID. DOC to PDF scheme example:
    POST https://v2.convertapi.com/doc/to/pdf?Secret=XXX
    {
        "Parameters": [
            {
                "ConversionTime": 3,
                "Name": "File",
                "FileValue": {
                    "Name": "my_file.doc",
                    "Data": "--Base64 encoded file content--"
                }
            }
        ]
    }
    Merge PDF scheme example:
    POST https://v2.convertapi.com/pdf/to/merge?Secret=XXX
    {
        "Parameters": [
            {
                "Name": "StoreFile",
                "Value": "true"
            },
            {
                "Name": "PdfVersion",
                "Value": "1.7"
            },
            {
                "Name": "Files",
                "FileValues": [
                    {
                        "Name": "file.pdf",
                        "Data": "--Base64 encoded file content--"
                    },
                    {
                        "Url": "http://example.com/myfile.docx"
                    },
                    {
                        "Id": "13232131"
                    }
                ]
            }
        ]
    }
  • multipart/form-data - Each request parameter must be in separate part. If there is an array type parameter, index must be appended to parameter name e.g. Files[0], Files[1], Files[2] etc. DOC to PDF example:
    POST /doc/to/pdf?secret=XXXX HTTP/1.1
    Host: v2.convertapi.com
    Cache-Control: no-cache
    Content-Type: multipart/form-data; boundary=----7MA4YWxkTrZu0gW
    
    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="StoreFile"
    
    true
    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="File"; filename="my_file.doc"
    Content-Type: 
    
    --FILE DATA--
    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="DocumentTitle"
    
    Test title
    ------7MA4YWxkTrZu0gW--
  • query parameters - Using query parameters it is possible to convert file which is accessible by URL or uploaded File ID. DOCX to PDF URL example:
    https://v2.convertapi.com/docx/to/pdf?Secret=XXX&File=http://example.com/myfile.docx&StoreFile=true
    If there is an array type parameter, index must be appended to parameter name e.g. Files[0], Files[1], Files[2] etc.

Response

Response headers and body contains this information:

  • ConversionTime - time in seconds that took to convert file. In this ammount of seconds your balance will be decreased after conversion.
  • FileName - name of converted file.
  • FileSize - converted file size in bytes.
  • FileData - converted file content.
  • FileUrl - link to converted file if "StoreFile" parameter is set to "true".

Response examples by media type:
  • application/json - response scheme can be explored in Test Request response box. Single file result example:
    {
        "ConversionTime": 2,
        "Files": [
            {
                "FileName": "my_file.pdf",
                "FileSize": 523672,
                "FileData": "--Base64 encoded file content--"
            }
        ]
    }
  • application/xml - XML scheme is analogous to JSON. Single file result example:
    <Conversion xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <ConversionTime>2</ConversionTime>
        <Files>
            <File>
                <FileName>my_file.pdf</FileName>
                <FileSize>522579</FileSize>
                <FileData>--Base64 encoded file content--</FileData>
                <Url i:nil="true" />
            </File>
        </Files>
    </Conversion>
  • multipart/mixed - each part contains converted file data or URL to the file. Single file result example:
    --43cf1475-ab15-4c6b-b5ee-e2cbcedfe92f
    ConversionTime: 3
    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename="my_file.pdf"; size=8475
    
    --FILE CONTENT--
                    
    --43cf1475-ab15-4c6b-b5ee-e2cbcedfe92f--
  • application/octet-stream - response body is result file content. File name can be found in content-disposition header field. Can be used with converters that produce only one file result.

Other features

  • Converted files that are stored on convertapi.com server can be accessible for further conversion operations. This method allows conversion chaining, without increased network load. Example: conversion PDF to JPG produces as many files as there are pages in PDF file. If these files are stored on the server and links to the files are passed to ZIP converter, result will be one ZIP file with JPG files of each PDF page.
  • If ?view=true is appended to a stored conversion result file download link, file will be viewed in browser rather than downloaded. Example:
    https://v2.convertapi.com/d/HQ5TRU5Z/my_file.pdf?view=true