Skip to main content
POST
/
v1
/
pdf
/
convert
/
from
/
url
PDF from URL
curl --request POST \
  --url https://api.pdf.co/v1/pdf/convert/from/url \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "url": "https://wikipedia.org/wiki/Wikipedia:Contact_us",
  "margins": "10px 10px 10px 10px",
  "papersize": "A4",
  "orientation": "Portrait",
  "printbackground": true,
  "mediatype": "print",
  "donotwaitfullload": false,
  "header": "<string>",
  "footer": "<string>",
  "legacyrendition": true,
  "name": "<string>",
  "async": false,
  "expiration": 60,
  "profiles": "{ \"CustomScript\": \";; // put some custom js script here \"}",
  "httpusername": "<string>",
  "httppassword": "<string>"
}
'
{
  "status": "success",
  "message": "Success",
  "url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf",
  "jobId": "6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA",
  "credits": 2,
  "remainingCredits": 1480582,
  "duration": 33
}

Authorizations

x-api-key
string
header
required

Body

application/json
url
string<uri>
default:https://wikipedia.org/wiki/Wikipedia:Contact_us
required

URL to the source file url attribute.

margins
string<{topMargin} {rightMargin} {bottomMargin} {leftMargin}>
default:5mm

Set custom margins, overriding CSS default margins. Specify the margins in the format {top} {right} {bottom} {left}. You can usepx,mm,cmorinunits. Also, you can set margins for all sides at once using a single value.

Example:

"10px 10px 10px 10px"

papersize
default:Letter

Specifies the paper size. Accepts standard sizes like 'Letter', 'Legal', 'Tabloid', 'Ledger', 'A0'–'A6'. You can also set a custom size by providing width and height separated by a space, with optional units: px (pixels), mm (millimeters), cm (centimeters), or in (inches). Examples: '200 300', '200px 300px', '200mm 300mm', '20cm 30cm', '6in 8in'.

Available options:
Letter,
Legal,
Tabloid,
Ledger,
A0,
A1,
A2,
A3,
A4,
A5,
A6
Example:

"A4"

orientation
enum<string>
default:Portrait

Sets the document orientation. Options: Portrait for vertical layout, and Landscape for horizontal layout.

Available options:
Portrait,
Landscape
printbackground
boolean
default:true

Set to false to disable background colors and images are included when generating PDFs from HTML/URL

mediatype
enum<string>
default:print

Controls how content is rendered when converting to PDF. Options: print (uses print styles), screen (uses screen styles), none (no media type applied).

Available options:
print,
screen,
none
donotwaitfullload
boolean
default:false

Controls how thoroughly the converter waits for a page to load before converting HTML to PDF --- false waits for full page load, while true speeds up conversion by waiting only for minimal loading.

header
string<html>

Set this to can add user definable HTML for the header to be applied on every page header. The format is html.

Set this to can add user definable HTML for the footer to be applied on every page bottom. The format is html.

legacyrendition
boolean

use legacy rendition (optional)

name
string

File name for generated output.

async
boolean
default:false

Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint. Also see Webhooks & Callbacks

expiration
number
default:60

Sets the expiration time for the output link, in minutes. After this period, generated output file(s) are automatically deleted from PDF.co Temporary Files Storage. The maximum allowed duration depends on your subscription plan. For permanent storage of input files (e.g., reusable images, PDF templates, documents), use PDF.co Built‑In Files Storage.

profiles
string
default:{ "CustomScript": ";; // put some custom js script here "}

Profiles are used configure extra options for specific API endpoints and may be unique to an API. For more information, see Profiles and the documentation of each endpoint for profiles specific to it.

httpusername
string

HTTP auth user name if required to access source URL.

httppassword
string

HTTP auth password if required to access source URL.

Response

Success.

status
string

Status of the API response.

Example:

"success"

message
string

Descriptive message for the response status.

Example:

"Success"

url
string<uri>

URL to the output file.

Example:

"https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf"

jobId
string

Unique identifier for the job.

Example:

"6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA"

credits
integer

Credits used for this operation.

Example:

2

remainingCredits
integer

Credits remaining after this operation.

Example:

1480582

duration
integer

Time taken to complete the request, in milliseconds.

Example:

33