v2

latestOpenAPI 3.0.12026-07-266846393.5 KB
PDF Conversion

PDF from URL

Convert URL into PDF. This method will process any JavaScript which the webpage triggers when it loads. For example if the the webpage triggers a JavaScript popup window then that will be included in the conversion process. There is no option to disable JavaScript on the supplied HTML page.

post/v1/pdf/convert/from/url

Request body

urlstring uri required

URL to the source file url attribute.

marginsstring {topMargin} {rightMargin} {bottomMargin} {leftMargin}

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.

orientation'Portrait' | 'Landscape'

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

printbackgroundboolean

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

mediatype'print' | 'screen' | 'none'

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

donotwaitfullloadboolean

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.

headerstring html

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

footerstring html

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

legacyrenditionboolean

use legacy rendition (optional)

namestring

File name for generated output.

asyncboolean

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

expirationnumber

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.

profilesstring

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.

httpusernamestring

HTTP auth user name if required to access source URL.

httppasswordstring

HTTP auth password if required to access source URL.

rendertimeoutnumber

timeout for rendering in milliseconds (optional)

templatedatastring

please set to string converted from JSON with data for Mustache template or leave empty if no template is used

customscriptstring

custom script to execute on page load

Example request

{
  "margins": "10px 10px 10px 10px"
}

Response

Success.

statusstring

Status of the API response.

messagestring

Descriptive message for the response status.

urlstring uri

URL to the output file.

jobIdstring

Unique identifier for the job.

creditsinteger

Credits used for this operation.

remainingCreditsinteger

Credits remaining after this operation.

durationinteger

Time taken to complete the request, in milliseconds.

Example response

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