Capture Website
To create a website screenshot, create a job with a capture-website task.
The available parameters differ based on output_format. Select a value below to show all available conversion options.
Task Parameters
capture-website.URL of the website
The target format to convert to.
Use a specific engine for the conversion.
Use a specific engine version for the conversion.
Choose a filename (including extension) for the output file.
Timeout in seconds after the task will be cancelled. By default, tasks time out after 5 hours.
Example Job
Using the parameters from above, you can create a job:
POSThttps://api.cloudconvert.com/v2/jobs{ "tasks": { "capture-my-website": { "operation": "capture-website", "url": "https://cloudconvert.com", "output_format": "pdf" }, "export-my-file": { "operation": "export/url", "input": "capture-my-website" } } }
# Install the CloudConvert CLI: npm install -g cloudconvert-cli $ cloudconvert capture-website \ -f pdf \ https://cloudconvert.com
$ curl -X POST "https://api.cloudconvert.com/v2/jobs" \ -H "Authorization: Bearer API_KEY" \ -H "Content-type: application/json" \ -d '{ "tasks": { "capture-my-website": { "operation": "capture-website", "url": "https://cloudconvert.com", "output_format": "pdf" }, "export-my-file": { "operation": "export/url", "input": "capture-my-website" } } }'
use \CloudConvert\CloudConvert; use \CloudConvert\Models\Job; use \CloudConvert\Models\Task; $cloudconvert = new CloudConvert(['api_key' => 'API_KEY']); $job = (new Job()) ->addTask( (new Task('capture-website', 'capture-my-website')) ->set('url', 'https://cloudconvert.com') ->set('output_format', 'pdf') ) ->addTask( (new Task('export/url', 'export-my-file')) ->set('input', 'capture-my-website') ); $cloudconvert->jobs()->create($job);
import CloudConvert from 'cloudconvert'; const cloudConvert = new CloudConvert('api_key'); let job = await cloudConvert.jobs.create({ "tasks": { "capture-my-website": { "operation": "capture-website", "url": "https://cloudconvert.com", "output_format": "pdf" }, "export-my-file": { "operation": "export/url", "input": "capture-my-website" } } });
import cloudconvert cloudconvert.configure(api_key='API_KEY') cloudconvert.Job.create(payload={ 'tasks': { 'capture-my-website': { 'operation': 'capture-website', 'url': 'https://cloudconvert.com', 'output_format': 'pdf' }, 'export-my-file': { 'operation': 'export/url', 'input': 'capture-my-website' } } })
Header and Footer
To add a custom header and/or footer, use header_template and footer_template. These parameters need to be set to the name of another import task, containing the templates. For example, you can use import/raw to provide these templates. As shown in the example below, you can use the magic CSS classes date, title, url, pageNumber, totalPages.
Alongside header_template / footer_template you need to set display_header_footer to true and and some spacing with margin_topand margin_bottom to show the header / footer.
{
"tasks": {
"import-my-footer": {
"operation": "import/raw",
"filename": "footer.html",
"file": "<span style='font-size: 10px'> Page <span class='pageNumber'></span> / <span class='totalPages'></span> </span>"
},
"import-my-header": {
"operation": "import/raw",
"filename": "header.html",
"file": "<span style='font-size: 10px'> This is a header. Date: <span class='date'></span> </span>"
},
"capture-my-website": {
"operation": "capture-website",
"url": "https://cloudconvert.com",
"output_format": "pdf",
"margin_top": 20,
"margin_bottom": 20,
"display_header_footer": true,
"footer_template": "import-my-footer",
"header_template": "import-my-header",
},
"export-my-file": {
"operation": "export/url",
"input": "capture-my-website"
}
}
}