Link Search Menu Expand Document

« return to view all profiles categories


For Zapier, Integromat and others plugins insert custom profiles into profiles field. For API calls please set value as string in profiles parameter as string.

HTML to PDF: insert HTML code before elements with a given class before converting

The profile below inserts HTML code before each h2 element. The inserted code will also force new page for printing for at the place of every h2 header. For example, if you take any Wikipedia page url, this profile will turn every h2 header into new page break.

For direct API calls set profiles param as string to the following:

{
     "CustomScript": "document.querySelectorAll('h2').forEach( elem => { elem.insertAdjacentHTML('beforebegin', '<div style=\"clear: both; page-break-after: always;\">INSERTED BEFORE H2 ELEMENT</div>') } )"
}

For Zapier, Integromat and others set profiles field to the following:

{
    "CustomScript": " document.querySelectorAll('h2').forEach( elem => { elem.insertAdjacentHTML('beforebegin', '<div style=\"clear: both; page-break-after: always;\">INSERTED BEFORE H2 ELEMENT</div>') } )"
}

This profile is injecting custom javascript into HTML code:

{ "CustomScript": "document.querySelectorAll('a').forEach(a => { a.href = '#' });" }

HTML to PDF: changing orientation from Portrait (default) to Landscape

To set landscape output for output PDF, please set profiles parameter to the following string:

{ "orientation": "landscape"}

HTML to PDF: setting margins for output PDF

You can set margins for the output PDF using profiles as well. Example:

{ "orientation": "Landscape", "margins": "10px 20px 50px 10px "}

The order of margin parameters margins is the following: top, right, bottom, left

Or you can set one single margin value and it will apply for all sides. For example, to set 10px margin for all sides:

{ "margins": "10px"}

HTML to PDF: change mediaType to define how input html or url is rendered

By default HTML To PDF and URL to PDF use print mediatype. It means that HTML code / URL is considered as printing when converted to PDF. Some websites may have a separate print only stylesheet for this purpose.

You can always switch it to use screen mediatype to convert to PDF exactly the same way it is displayed on screen to users. To switch to screen mode set the following profiles parameter:

{ 'mediaType': 'screen' }

HTML to PDF: hiding selected html content using a custom js script before converting

URL to PDF and HTML to PDF can run small javascript scripts before converting to PDF. You can hide selected elements using this customScript param in profiles.

For example, let’s hide all elements with navbar class name:

{ "customscript": "document.querySelectorAll('.navbar').forEach(el => { el.style.display = 'none' });"}

You can also hide elements by their id instead of class:

{ "customscript": "document.querySelectorAll('#navbar').forEach(el => { el.style.display = 'none' });"}

HTML to PDF: do not wait until full page load

URL / HTML to PDF waits for full page load by default. But some page with dynamic content (such as YouTube videos) may take forever to fully load or continuue loading new data. This may take up to few minutes while all visible content is already loaded.

with this custom profile and doNotWaitUntilFullLoad param you can turn off waiting for all dynamic elements to fully load:

{ "doNotWaitUntilFullLoad": false }

« return to view all profiles categories