Loading...

PDF & Screenshot

PDF & Screenshot is a component of SmartBrowz that lets you generate visual documents of websites and web applications. It is a powerful tool that can be used to convert webpages to PDF, to use during UI debugging, and to understand visual components from end-users’ perspective, while implementing permitted crawling operations, just to name a few.

You can introduce this functionality in your Catalyst application using the API below.

Generate PDF Using HTML/URL

PDF Description

You can use this API to generate PDF documents of webpages by using HTML code or URL as your input.

PDF Request Details

Request URL

POST

{api-domain}/browser360/v1/project/{project_id}/convert

copy

api-domain
URL
The DC-specific domain to access Catalyst API

project_id
Numerical
The unique ID of the project

Scope

ZohoCatalyst.pdfshot.EXECUTE

Request Headers

Authorization: Zoho-oauthtoken {oauth_token}
Content-Type: application/json

Request JSON Properties

display_header_footer boolean
optional
Pass the value as true to show the header and footer of the webpage.
Default: false.
footer_template string
optional
HTML template for the print footer. Has the same constraints and support for special classes as PDFOptions.headerTemplate.
format PaperFormat
optional
Size of the paper. Example: A4, A3.
header_template string
optional

HTML template for the print header. Should be valid HTML with the following classes to inject values into them:

date string
optional
Formatted print date

title string
mandatory
Title of the document

url string
mandatory
URL of the document

page_number string
optional
Current page number

total_pages string
optional
Total pages in the document

landscape boolean
optional
Pass the value as true to print in a landscape orientation
margin PDFMargin
optional
Set the PDF margins
omit_background boolean
optional
Hides the default white background and allows generating PDFs with a transparent background
page_ranges string
optional
Paper ranges to print. Example: 1-5, 8, 11-13.
prefer_css_pageSize boolean
optional
Pass the value as true to prioritize the CSS @page size declared in the page over what is declared in the width, height, or format option
print_background boolean
optional
Pass the value as true to print the background graphics
scale number
optional
Scales the rendering of the web page. Acceptable Values: Between 0.1 and 2.
timeout number
optional
Timeout in milliseconds. Pass the value as 0 to disable the timeout.
width string | number
optional
Sets the width of paper. You can pass in a number or a string with a unit.
timeout number
optional
Maximum wait time in milliseconds. Pass the value as 0 to disable the timeout.

The default value can be changed by using the
page.set_default_timeout() or page.set_default_navigation_timeout() methods.
wait_until string | number
optional

PDF Response Details

The response will return the PDF document generated.



Generate Screenshot Using HTML/URL

Screenshot Description

You can use this API to generate screenshots of webpages using HTML code or URL as your input.

Screenshot Request Details

Request URL

POST

{api-domain}/browser360/v1/project/{project_id}/convert

copy

project_id
Numerical
The unique ID of the project

Scope

ZohoCatalyst.pdfshot.EXECUTE

Request JSON Properties

capture_beyond_viewport boolean
mandatory
Pass the value as true to capture the screenshot beyond the viewport
clip screenshot_clip
mandatory
Object that specifies the clipping region of the page
encoding 'base64' | 'binary'
mandatory
Encoding of the image
from_surface boolean
mandatory
Pass the value as true to capture the screenshot from the surface rather than the view.
full_page boolean
mandatory
Pass the value as true to take a screenshot of the entire page
omit_background boolean
mandatory
Hides the default white background and allows capturing screenshots with a transparent background
quality number
optional
Quality of the image. Not applicable to .png images. Acceptable Values: Between 0 to 100. Maximum wait time in milliseconds. Pass the value as 0 to disable the timeout.
wait_until string | number
optional
password string
optional
Will hold the value of the password that protects your PDF document.

Screenshot Response Details

The response will return a screenshot that was generated.

Note: Any Browser action or operation that you code using the Browser Logic function, or any browser automation or web scraping task that you perform using any component of Catalyst SmartBrowz is at your own risk. We strongly recommend you use the SmartBrowz components to perform operations on domains that permit the actions, or with proper approval. Additionally, while Catalyst does provide a secure infrastructure to code your functions, any consequence of the logic you code using Catalyst functions is yours alone.
CURL Request - PDF from HTML/URL
copy

curl -X POST \ ‘https://api.catalyst.zoho.com/browser360/v1/project/10470000000272001/convert' -H “Authorization: Zoho-oauthtoken 1000.910*************************16.2f*************************57”
-H ‘Content-Type: application/json’ –d ‘{ “url”: “https://www.example.com”, “output_options”: { “output_type”: “pdf” }, “pdf_options” : { “scale” : 1, “display_header_footer” : true, “header_template” : “<style> #header, #footer { margin: 0 !important; padding: 0 !important; font-size: 9px; -webkit-print-color-adjust: exact;}</style><div style=\width:100%><span class=\date&gt;</span><span class=\title\ style=\float:right&gt;</span</div>”, “footer_template” : “<style> #header, #footer { margin: 0 !important; padding: 0 !important; font-size: 9px; -webkit-print-color-adjust: exact;}</style><div style=\width:100%&gt;<span class=\url&gt;</span><div style=\float:right&gt;<span class=\pageNumber&gt;</span> / <span class=\totalPages&gt;</span></div></div>”, “print_background” : false, “landscape” : false, “page_ranges” : “1”, “format” : “A4”, “width” : “100”, “height” : “100”, “margin” : { “top” : “1cm”, “bottom” : “1cm”, “left” : “1cm”, “right”: “1cm” },
“omit_background” : false }, “page_options”:{ “css” : { “content” : “body{background: lightgrey}” }, “viewport” : { “width”: 1440, “height”: 900 }, “javascript_enabled” : true }, “navigation_options”:{ “timeout” : 5000, “wait_until” : “networkidle0” } }’

View more
CURL Request - Screenshot from HTML/URL
copy

curl -X POST \ ‘https://api.catalyst.zoho.com/browser360/v1/project/10470000000272001/convert' -H “Authorization: Zoho-oauthtoken 1000.910*************************16.2f*************************57”
-H ‘Content-Type: application/json’ –d’{ “url”: “https://www.example.com”, “output_options”: { “output_type”: “screenshot” }, “screenshot_options”: { “type”: “jpeg”, “quality”: 100, “full_page”: false, “omit_background”: false, “capture_beyond_viewport”: true, “clip”: { “x”: 50, “y”: 100, “width”: 1000, “height”: 100 } }, “page_options”: { “css”: { “content”: “body{background: lightgrey}” }, “viewport”: { “width”: 1440, “height”: 900 }, “javascript_enabled”: true }, “navigation_options”: { “timeout”: 5000, “wait_until”: “networkidle0” } }’

View more