Pdfcrowd JavaScript Library

The following methods can be used in your custom JavaScripts (on load, on print) that run during the Pdfcrowd conversion process.

function libPdfcrowd::insertStyle(dict options)
Inserts custom CSS into the document.
Parameter Description
options
associative array with options:
  • style - CSS string
  • asLast - set to true to insert CSS at the end of <body>, false to insert it at the beginning of <head>, default value is false
  • recursive - set to true to descend into iframes, default value is false
Disable hyperlinks, the href attribute is removed from all elements.
Parameter Description
function libPdfcrowd::removeBySelector(dict options)
Remove elements from HTML.
Parameter Description
options
associative array with options:
  • selector - CSS selector defining elements to be removed
  • element - root DOM element, default value is document
  • recursive - set to true to descend into iframes, default value is false
function libPdfcrowd::removeZIndexHigherThan(dict options)
Remove div, nav, header and aside elements with z-index greater than the specified value.
Parameter Description
options
associative array with options:
  • zlimit - maximal visible z-index
  • element - root DOM element, default value is document
  • recursive - set to true to descend into iframes, default value is false
function libPdfcrowd::highlightHtmlElements(dict options)
Visually highlight HTML elements. It's useful for a renderer debugging. It's done by altering the style of all HTML elements. Padding and margin options can be used for setting a space between all elements to distinguish them. elementIdColor can be used for adding a text with an element ID to find the element easily.
Parameter Description
options
associative array with options:
  • backgroundColor - background color, default value is 'rgba(255, 191, 0, 0.1)', set to null for not modifying background color
  • borderColor - border color, default value is 'orange', set to null for not modifying border color
  • elementIdColor - color of the text displaying element's ID, default value is 'red', set to null for no text
  • randomColors - set to true to use random colors
  • padding - padding, default value is null
  • margin - margin, default value is null