HTML to Image / .NET Reference

class HtmlToImageClient

All setter methods return HtmlToImageClient object unless specified otherwise.

Constructor

public HtmlToImageClient(string userName, string apiKey)

Constructor for the PDFCrowd API client. Initialize a new instance of the conversion client with your PDFCrowd account credentials.

You must provide both your username and API key. This establishes the authenticated connection for all subsequent conversion operations.

Parameters:
  • userName - Your username at PDFCrowd.
  • apiKey - Your API key.

Conversion Format

public HtmlToImageClient setOutputFormat(string outputFormat)

The output file format.

Parameter:
  • outputFormat
    Allowed Values:
    • png
    • jpg
    • gif
    • tiff
    • bmp
    • ico
    • ppm
    • pgm
    • pbm
    • pnm
    • psb
    • pct
    • ras
    • tga
    • sgi
    • sun
    • webp
    Default:
    png

Conversion Input

public byte[] convertUrl(string url)

Convert a web page from a URL.

Use this as the primary method for converting web content, online documents, or any publicly accessible URL to the desired output format. Returns the conversion result as a byte array for further processing or direct use.

Parameter:
  • url - The address of the web page to convert.
    Constraint:
    • Supported protocols are http:// and https://.
Returns:
byte[] - Byte array containing the conversion output.

public void convertUrlToStream(string url, Stream outStream)

Convert a web page from a URL and write the conversion result directly to an output stream.

Use this when you need to handle large conversion results, integrate with streaming pipelines, or build server applications that process conversions continuously.

Parameters:
  • url - The address of the web page to convert.
    Constraint:
    • Supported protocols are http:// and https://.
  • outStream (OutputStream) - The output stream that will contain the conversion output.

public void convertUrlToFile(string url, string filePath)

Convert a web page from a URL and save the conversion result directly to a local file.

Use this for simple file-based workflows, batch processing, or when you need to persist conversion output to disk. The most straightforward method for URL-to-file conversions.

Parameters:
  • url - The address of the web page to convert.
    Constraint:
    • Supported protocols are http:// and https://.
  • filePath - The output file path.

public byte[] convertFile(string file)

Convert a local file to the desired output format.

Use this for processing files already on your system, converting uploaded documents, or batch processing local content. Returns the conversion result as a byte array for in-memory processing.

Parameter:
  • file - The path to a local file to convert.
    The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip).
    If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets.
    Constraints:
    • The file must exist and not be empty.
    • The file name must have a valid extension.
Returns:
byte[] - Byte array containing the conversion output.

public void convertFileToStream(string file, Stream outStream)

Convert a local file and write the conversion result directly to an output stream.

Use this when working with large conversion results, integrating with streaming frameworks, or building applications that need direct stream-to-stream processing.

Parameters:
  • file - The path to a local file to convert.
    The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip).
    If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets.
    Constraints:
    • The file must exist and not be empty.
    • The file name must have a valid extension.
  • outStream (OutputStream) - The output stream that will contain the conversion output.

public void convertFileToFile(string file, string filePath)

Convert a local file and save the conversion result to another local file.

Use this for file-based batch processing, document transformation workflows, or when both input and output are file-based. The simplest method for file-to-file conversions.

Parameters:
  • file - The path to a local file to convert.
    The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip).
    If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets.
    Constraints:
    • The file must exist and not be empty.
    • The file name must have a valid extension.
  • filePath - The output file path.

public byte[] convertString(string text)

Convert a string containing source content to the desired output format.

Use this for converting dynamically generated content, templates, user input, or any text-based data held in memory. Ideal for real-time content generation and API integrations.

Parameter:
  • text - The string content to convert.
Returns:
byte[] - Byte array containing the conversion output.

public void convertStringToStream(string text, Stream outStream)

Convert a string containing source content and write the conversion result directly to an output stream.

Use this when processing dynamically generated content with large outputs, integrating with streaming APIs, or building high-throughput web applications.

Parameters:
  • text - The string content to convert.
  • outStream (OutputStream) - The output stream that will contain the conversion output.

public void convertStringToFile(string text, string filePath)

Convert a string containing source content and save the conversion result to a local file.

Use this for persisting dynamically generated content, creating documents from templates, or saving user-generated conversions. Combines in-memory source with file-based output.

Parameters:
  • text - The string content to convert.
  • filePath - The output file path.

public byte[] convertStream(Stream inStream)

Convert content from an input stream to the desired output format.

Use this when integrating with I/O pipelines, processing data from network streams or file handles, or when the source data is provided as a stream by your application.

Parameter:
  • inStream (InputStream) - The input stream with source data.
    The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).
    The archive can contain HTML code and its external assets (images, style sheets, javascript).
Returns:
byte[] - Byte array containing the conversion output.

public void convertStreamToStream(Stream inStream, Stream outStream)

Convert content from an input stream and write the conversion result to an output stream.

Use this when both input and output need to be streams, integrating with streaming frameworks, or building conversion services that process data in stream form throughout.

Parameters:
  • inStream (InputStream) - The input stream with source data.
    The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).
    The archive can contain HTML code and its external assets (images, style sheets, javascript).
  • outStream (OutputStream) - The output stream that will contain the conversion output.

public void convertStreamToFile(Stream inStream, string filePath)

Convert content from an input stream and save the conversion result to a local file.

Use this when processing streaming uploads that need to be saved, handling network data sources with file-based output, or building services that accept stream input and produce file output.

Parameters:
  • inStream (InputStream) - The input stream with source data.
    The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).
    The archive can contain HTML code and its external assets (images, style sheets, javascript).
  • filePath - The output file path.

public HtmlToImageClient setZipMainFilename(string filename)

Set the file name of the main HTML document stored in the input archive. Use this when your ZIP/TAR archive contains multiple HTML files and you need to specify which one to convert.

If not specified, the first HTML file found in the archive is automatically used for conversion.

Parameter:
  • filename - The file name.

Image Output

public HtmlToImageClient setScreenshotWidth(int width)

Set the output image width in pixels.

Parameter:
  • width (int)
    Constraint:
    • The accepted range is 96-65000.
    Default:
    1024
Example:
  • Full HD width: setScreenshotWidth(1920)

public HtmlToImageClient setScreenshotHeight(int height)

Set the output image height in pixels. If it is not specified, actual document height is used.

Parameter:
  • height (int)
    Constraint:
    • Must be a positive integer.
Example:
  • Full HD height: setScreenshotHeight(1080)

public HtmlToImageClient setScaleFactor(int factor)

Set the scaling factor (zoom) for the output image.

Parameter:
  • factor (int) - The percentage value.
    Constraint:
    • Must be a positive integer.
    Default:
    100
Example:
  • Reduce image for thumbnails: setScaleFactor(50)

public HtmlToImageClient setBackgroundColor(string color)

The output image background color in RGB or RGBA hex format. Use transparent (00000000) for PNG overlays or solid colors for web display.

Availability:
API client >= 5.0.0, converter >= 20.10. See versioning.
Parameter:
  • color
    Constraint:
    • The value must be in RRGGBB or RRGGBBAA hexadecimal format.
Examples:
  • red color: setBackgroundColor("FF0000")
  • fully transparent background: setBackgroundColor("00000000")
  • green color with 50% opacity: setBackgroundColor("00ff0080")
  • green color: setBackgroundColor("00ff00")

General Options

public HtmlToImageClient setUsePrintMedia(bool value)

Use the print version of the page if available via @media print CSS rules. Enable this when converting websites that have print-optimized styles. Many sites hide navigation, ads, and sidebars in print mode.

Produces cleaner PDFs by using the design the website creator intended for printing.

Parameter:
  • value (bool) - Set to true to use the print version of the page.
    Default:
    false

public HtmlToImageClient setNoBackground(bool value)

Do not print the background graphics to create printer-friendly PDFs. Use this when documents will be physically printed to save ink costs and improve readability.

Removes background colors, images, and patterns while preserving text and foreground content. Particularly useful for documents with dark backgrounds or decorative elements.

Parameter:
  • value (bool) - Set to true to disable the background graphics.
    Default:
    false

public HtmlToImageClient setDisableJavascript(bool value)

Do not execute JavaScript during conversion. Use this to improve conversion speed when JavaScript is not needed, prevent dynamic content changes, or avoid security risks from untrusted scripts.

Note that disabling JavaScript means lazy-loaded images and AJAX content will not load.

Parameter:
  • value (bool) - Set to true to disable JavaScript in web pages.
    Default:
    false

public HtmlToImageClient setDisableImageLoading(bool value)

Do not load images during conversion to create text-only PDFs. Use this to significantly speed up conversion, reduce file size, or create accessible text-focused documents.

Ideal for converting documentation where images are not needed, reducing bandwidth usage, or creating lightweight PDFs for email distribution.

Parameter:
  • value (bool) - Set to true to disable loading of images.
    Default:
    false

public HtmlToImageClient setDisableRemoteFonts(bool value)

Disable loading fonts from remote sources. Use this to speed up conversion by avoiding font download delays, ensure consistent rendering with system fonts, or work around font loading failures.

Note that text will fall back to system fonts, which may change the document's appearance.

Parameter:
  • value (bool) - Set to true to disable loading remote fonts.
    Default:
    false

public HtmlToImageClient setUseMobileUserAgent(bool value)

Deprecated Replaced with: setConverterUserAgent

Use a mobile user agent when making requests to the source URL.

Availability:
API client >= 5.3.0, converter >= 20.10. See versioning.
Parameter:
  • value (bool) - Set to true to use a mobile user agent.
    Default:
    false

public HtmlToImageClient setLoadIframes(string iframes)

Specifies how iframes are handled during conversion. Use "all" to include all embedded content (videos, maps, widgets). Use "same-origin" to include only content from the same domain for security purposes. Use "none" to exclude all iframes for faster conversion and to avoid third-party content issues.

Disabling iframes can significantly improve performance and reliability.

Availability:
API client >= 5.0.0, converter >= 20.10. See versioning.
Parameter:
  • iframes
    Allowed Values:
    • all — All iframes are loaded.
    • same-origin — Only iframes with the same origin as the main page are loaded.
    • none — Iframe loading is disabled.
    Default:
    all

public HtmlToImageClient setBlockAds(bool value)

Automatically block common advertising networks and tracking scripts during conversion, producing cleaner PDFs with faster conversion times. Filters out third-party ad content, analytics beacons, and ad network resources.

Ideal for converting news sites, blogs, or any ad-heavy content where ads distract from the main message. May occasionally block legitimate third-party content - disable if critical third-party resources are missing.

Parameter:
  • value (bool) - Set to true to block ads in web pages.
    Default:
    false

public HtmlToImageClient setDefaultEncoding(string encoding)

Specify the character encoding when the HTML lacks proper charset declaration or has incorrect encoding. Prevents garbled text for non-English content, especially legacy pages without UTF-8 encoding.

Set to "utf-8" for modern content, "iso-8859-1" for Western European legacy pages, or other encodings for specific regional content. Only needed when auto-detection fails and you see corrupted characters in the output.

Parameter:
  • encoding - The text encoding of the HTML content.
    Default:
    auto detect
Examples:
  • Set to use Latin-2 encoding: setDefaultEncoding("iso8859-2")
  • Set to use UTF-8 encoding: setDefaultEncoding("utf-8")

public HtmlToImageClient setLocale(string locale)

Set the locale for the conversion to control regional formatting of dates, times, and numbers. Use this when converting content for specific regions - for example, set to "en-US" for MM/DD/YYYY dates and comma thousand separators, or "de-DE" for DD.MM.YYYY dates and period thousand separators.

Essential for financial reports, invoices, or localized content.

Availability:
API client >= 5.0.0, converter >= 20.10. See versioning.
Parameter:
  • locale - The locale code according to ISO 639.
    Default:
    en-US
Example:
  • Set to use Japanese locale: setLocale("ja-JP")

public HtmlToImageClient setHttpAuth(string userName, string password)

Set credentials to access HTTP basic authentication protected websites. Use this when converting content behind HTTP authentication, such as development servers, staging environments, or password-protected documentation.

Provide both username and password to authenticate requests. Essential for converting internal resources or protected content.

Parameters:
  • userName - Set the HTTP authentication user name. Required to access protected web pages or staging environments.
  • password - Set the HTTP authentication password. Required to access protected web pages or staging environments.

public HtmlToImageClient setCookies(string cookies)

Set HTTP cookies to be included in all requests made by the converter to access authenticated or session-based content. Use this when converting pages that require login, maintain user sessions, or personalize content based on cookies.

Essential for converting member-only areas, dashboards, or any content behind cookie-based authentication. Format as semicolon-separated name=value pairs.

Parameter:
  • cookies - The cookie string.
Example:
  • Multiple cookies for authentication: setCookies("session=6d7184b3bf35;token=2710")

public HtmlToImageClient setVerifySslCertificates(bool value)

Enforce SSL certificate validation for secure connections, preventing conversions from sites with invalid certificates. Enable when converting from production sites with valid certificates to ensure security.

When disabled, allows conversion from any HTTPS site regardless of certificate validity - including development servers with self-signed certificates, internal corporate sites with expired certificates, or local testing environments.

Parameter:
  • value (bool) - Set to true to enable SSL certificate verification.
    Default:
    false

public HtmlToImageClient setFailOnMainUrlError(bool failOnError)

Abort the conversion if the HTTP status code of the main URL is greater than or equal to 400 (client/server errors). Use this in automated workflows to catch broken URLs or authentication failures early rather than producing invalid PDFs. Ensures your system does not silently generate error page PDFs when source content is unavailable.

Parameter:
  • failOnError (bool) - Set to true to abort the conversion.
    Default:
    false

public HtmlToImageClient setFailOnAnyUrlError(bool failOnError)

Abort the conversion if any sub-request (images, stylesheets, scripts) fails with HTTP 400+ errors. Use this for strict quality control when all assets must load successfully.

Parameter:
  • failOnError (bool) - Set to true to abort the conversion.
    Default:
    false

public HtmlToImageClient setNoXpdfcrowdHeader(bool value)

Do not send the X-Pdfcrowd HTTP header in HTTP requests made by the converter. Use this if your target server blocks or logs requests with this header, or for privacy when you do not want sites to know you are using PDFCrowd. Some security systems may block requests with non-standard headers.

Parameter:
  • value (bool) - Set to true to disable sending X-Pdfcrowd HTTP header.
    Default:
    false

public HtmlToImageClient setCustomCss(string css)

Apply custom CSS to the input HTML document to modify the visual appearance and layout of your content dynamically. Use this to override default styles, adjust spacing, change fonts, or fix layout issues without modifying the source HTML.

Use !important in your CSS rules to prioritize and override conflicting styles.

Availability:
API client >= 5.14.0, converter >= 20.10. See versioning.
Parameter:
  • css - A string containing valid CSS.
Examples:
  • Set the page background color to gray: setCustomCss("body { background-color: gray; }")
  • Do not show nav HTML elements and the element with ad-block ID in the output PDF: setCustomCss("nav, #ad-block { display: none !important; }")

public HtmlToImageClient setCustomJavascript(string javascript)

Run a custom JavaScript after the document is loaded and ready to print. Use this to modify page content before conversion, remove unwanted elements, or trigger specific page states. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...).

In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.

Parameter:
  • javascript - A string containing a JavaScript code.
Example:
  • Set the page background color to gray: setCustomJavascript("document.body.style.setProperty('background-color', 'gray', 'important')")

public HtmlToImageClient setOnLoadJavascript(string javascript)

Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.

Parameter:
  • javascript - A string containing a JavaScript code.
Example:
  • Set the page background color to gray: setOnLoadJavascript("document.body.style.setProperty('background-color', 'gray', 'important')")

public HtmlToImageClient setCustomHttpHeader(string header)

Set a custom HTTP header to be included in all requests made by the converter. Use this to pass authentication tokens to protected sites, add tracking headers for analytics, or provide API keys for accessing private content.

Essential when converting content from APIs or internal systems that require special headers for access control.

Parameter:
  • header
    Constraint:
    • A string containing the header name and value separated by a colon.
Example:
  • API client tracking header: setCustomHttpHeader("X-My-Client-ID:k2017-12345")

public HtmlToImageClient setJavascriptDelay(int delay)

Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Use this to ensure lazy-loaded images, AJAX content, or animations complete before conversion. Your license defines the maximum wait time by "Max Delay" parameter.

Parameter:
  • delay (int) - The number of milliseconds to wait.
    Constraint:
    • Must be a positive integer or 0.
    Default:
    200
Example:
  • Wait for 2 seconds: setJavascriptDelay(2000)

public HtmlToImageClient setElementToConvert(string selectors)

Convert only the specified element from the main document and its children. Use this to extract specific portions of a page (like article content) while excluding navigation, headers, footers, or sidebars. The element is specified by one or more CSS selectors. If the element is not found, the conversion fails. If multiple elements are found, the first one is used.

Parameter:
Examples:
  • The first element with the id main-content is converted: setElementToConvert("#main-content")
  • The first element with the class name main-content is converted: setElementToConvert(".main-content")
  • The first element with the tag name table is converted: setElementToConvert("table")
  • The first element with the tag name table or with the id main-content is converted: setElementToConvert("table, #main-content")
  • The first element <p class="article"> within <div class="user-panel main"> is converted: setElementToConvert("div.user-panel.main p.article")

public HtmlToImageClient setElementToConvertMode(string mode)

Control how CSS styles are applied when converting only part of a page. The "cut-out" option extracts the element into a new document root, which may break CSS selectors like "body > div". The "remove-siblings" option keeps the element in its original DOM position but deletes other elements, preserving descendant selectors. The "hide-siblings" option keeps all elements but hides non-selected ones with display:none, preserving all CSS context.

Parameter:
  • mode
    Allowed Values:
    • cut-out — The element and its children are cut out of the document.
    • remove-siblings — All element's siblings are removed from the DOM. Keeps target element in position but may break descendant CSS selectors.
    • hide-siblings — All element's siblings are hidden using display:none. Preserves CSS context while hiding non-target content.
    Default:
    cut-out

public HtmlToImageClient setWaitForElement(string selectors)

Wait for the specified element in a source document. Use this when specific dynamic content must be ready before conversion, avoiding unnecessary delays from a fixed JavaScript delay. The element is specified by one or more CSS selectors. The element is searched for in the main document and all iframes.

If the element is not found, the conversion fails. Your license defines the maximum wait time by the "Max Delay" parameter.

Parameter:
Examples:
  • Wait until an element with the id main-content is found: setWaitForElement("#main-content")
  • Wait until an element with the class name main-content is found: setWaitForElement(".main-content")
  • Wait until an element with the tag name table is found: setWaitForElement("table")
  • Wait until an element with the tag name table or with the id main-content is found: setWaitForElement("table, #main-content")
  • Wait until <p class="article"> is found within <div class="user-panel main">: setWaitForElement("div.user-panel.main p.article")

public HtmlToImageClient setAutoDetectElementToConvert(bool value)

The main HTML element for conversion is detected automatically. Use this when you want to extract article or main content without knowing the exact CSS selector, automatically excluding navigation and sidebars.

Availability:
API client >= 5.5.0, converter >= 20.10. See versioning.
Parameter:
  • value (bool) - Set to true to detect the main element.
    Default:
    false

public HtmlToImageClient setReadabilityEnhancements(string enhancements)

Automatically enhance the input HTML to improve readability by removing clutter and reformatting content. Use this when converting web pages with excessive navigation, ads, or sidebars that distract from the main content.

Different versions (v1-v4) use progressively aggressive algorithms - start with "v1" and increase if more cleanup is needed. Ideal for converting blog posts, articles, or documentation into clean PDFs.

Availability:
API client >= 5.5.0, converter >= 20.10. See versioning.
Parameter:
  • enhancements
    Allowed Values:
    • none — No enhancements are used.
    • readability-v1 — Version 1 of the enhancements is used. Basic cleanup for simple pages with moderate clutter.
    • readability-v2 — Version 2 of the enhancements is used. More aggressive cleanup for pages with more ads and navigation.
    • readability-v3 — Version 3 of the enhancements is used. Strong cleanup for heavily cluttered pages with multiple sidebars.
    • readability-v4 — Version 4 of the enhancements is used. Maximum cleanup for extremely cluttered pages. May remove some content.
    Default:
    none

Data

Methods related to HTML template rendering.

public HtmlToImageClient setDataString(string dataString)

Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.

Parameter:
  • dataString - The input data string.
Example:
  • Template variables for mail merge: setDataString("{"recipient": "Anna May", "sender": "John Doe"}")

public HtmlToImageClient setDataFile(string dataFile)

Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.

Parameter:
  • dataFile - The file path to a local file containing the input data.
Example:
  • External data for template rendering: setDataFile("/home/user/john/data.json")

public HtmlToImageClient setDataFormat(string dataFormat)

Specify the input data format. Use "auto" for automatic detection or explicitly set to JSON, XML, YAML, or CSV when format is known.

Parameter:
  • dataFormat - The data format.
    Allowed Values:
    • auto — The data format is auto-detected.
    • json
    • xml
    • yaml
    • csv
    Default:
    auto

public HtmlToImageClient setDataEncoding(string encoding)

Set the encoding of the data file set by setDataFile.

Parameter:
  • encoding - The data file encoding.
    Default:
    utf-8
Example:
  • Set to use Latin-2 encoding: setDataEncoding("iso8859-2")

public HtmlToImageClient setDataIgnoreUndefined(bool value)

Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.

Parameter:
  • value (bool) - Set to true to ignore undefined variables.
    Default:
    false

public HtmlToImageClient setDataAutoEscape(bool value)

Auto escape HTML symbols in the input data before placing them into the output.

Parameter:
  • value (bool) - Set to true to turn auto escaping on.
    Default:
    false

public HtmlToImageClient setDataTrimBlocks(bool value)

Auto trim whitespace around each template command block.

Parameter:
  • value (bool) - Set to true to turn auto trimming on.
    Default:
    false

public HtmlToImageClient setDataOptions(string options)

Set the advanced data options:
  • csv_delimiter - The CSV data delimiter, the default is ,.
  • xml_remove_root - Remove the root XML element from the input data.
  • data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
Parameter:
  • options - Comma separated list of options.
Examples:
  • Use semicolon to separate CSV data: setDataOptions("csv_delimiter=;")
  • Name the root of data rows and use the name in the template loop {% for row in rows %}...{% endfor %}: setDataOptions("data_root=rows")
  • Remove XML root so the HTML template can be simpler: setDataOptions("xml_remove_root=1")

Miscellaneous

public HtmlToImageClient setDebugLog(bool value)

Turn on debug logging to troubleshoot conversion issues. Details about the conversion process, including resource loading, rendering steps, and error messages are stored in the debug log. Use this when conversions fail or produce unexpected results. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

Parameter:
  • value (bool) - Set to true to enable debug logging.
    Default:
    false

public string getDebugLogUrl()

Get the URL of the debug log for the last conversion.

Returns:
string - The link to the debug log.

public int getRemainingCreditCount()

Get the number of conversion credits available in your account. Use this to monitor your credit usage and implement alerts before running out of credits.
This method can only be called after a call to one of the convertXtoY methods.
The returned value can differ from the actual count if you run parallel conversions.
The special value 999999 is returned if the information is not available.

Returns:
int - The number of credits.

public int getConsumedCreditCount()

Get the number of credits consumed by the last conversion. Use this to track costs per conversion, especially for complex documents or operations that may consume multiple credits.

Returns:
int - The number of credits.

public string getJobId()

Get the unique job ID for the conversion. Use this to track conversions in your logs, correlate with debug logs, or reference specific conversions when contacting support.

Returns:
string - The unique job identifier.

public int getOutputSize()

Get the size of the output document in bytes. Use this to check file sizes before delivery, implement size-based quotas, or optimize storage allocation.

Returns:
int - The count of bytes.

public string getVersion()

Get the version details including API version, converter version, and client library version. Use this for debugging, logging, or ensuring compatibility when reporting issues.

Returns:
string - API version, converter version, and client version.

public HtmlToImageClient setTag(string tag)

Tag the conversion with a custom value for tracking and analytics. Use this to categorize conversions by customer ID, document type, or business unit. The tag appears in conversion statistics. A value longer than 32 characters is cut off.

Parameter:
  • tag - A string with the custom tag.
Example:
  • Track job in analytics: setTag("client-1234")

public HtmlToImageClient setHttpProxy(string proxy)

A proxy server used by the conversion process for accessing the source URLs with HTTP scheme. This can help circumvent regional restrictions or provide limited access to your intranet.

Parameter:
  • proxy
    Constraint:
    • The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
Examples:
  • Corporate proxy server: setHttpProxy("myproxy.com:8080")
  • Direct IP proxy connection: setHttpProxy("113.25.84.10:33333")

public HtmlToImageClient setHttpsProxy(string proxy)

A proxy server used by the conversion process for accessing the source URLs with HTTPS scheme. This can help circumvent regional restrictions or provide limited access to your intranet.

Parameter:
  • proxy
    Constraint:
    • The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
Examples:
  • Secure proxy for HTTPS: setHttpsProxy("myproxy.com:443")
  • Direct secure proxy IP: setHttpsProxy("113.25.84.10:44333")

public HtmlToImageClient setClientCertificate(string certificate)

A client certificate to authenticate the converter on your web server. The certificate is used for two-way SSL/TLS authentication (mutual TLS) and adds extra security. Use this when converting content from servers that require client certificate authentication for access.

Parameter:
  • certificate - The file must be in PKCS12 format.
    Constraint:
    • The file must exist and not be empty.
Example:
  • Custom CA certificate path: setClientCertificate("/home/user/john/pdfcrowd.crt")

public HtmlToImageClient setClientCertificatePassword(string password)

A password for the PKCS12 file with a client certificate if the certificate file is password-protected.

Parameter:
  • password
Example:
  • PKCS12 certificate password: setClientCertificatePassword("123456")

Tweaks

Expert options for fine-tuning output.

public HtmlToImageClient setMaxLoadingTime(int maxTime)

Set the maximum time for loading the page and its resources. After this time, all requests will be considered successful. This can be useful to ensure that the conversion does not timeout. Use this method if there is no other way to fix page loading.

Availability:
API client >= 5.15.0, converter >= 20.10. See versioning.
Parameter:
  • maxTime (int) - The number of seconds to wait.
    Constraint:
    • The accepted range is 10-30.

public HtmlToImageClient setConverterUserAgent(string agent)

Specify the User-Agent HTTP header that will be used by the converter when a request is made to the converted web page.

Availability:
API client >= 6.4.0 See versioning.
Parameter:
  • agent - The user agent.
    Allowed Values:
    • chrome-desktop — The user-agent for desktop chrome corresponding to the converter used.
    • chrome-mobile — The user-agent for mobile chrome corresponding to the converter used.
    • latest-chrome-desktop — The user-agent of the recently released Chrome browser on desktops.
    • latest-chrome-mobile — The user-agent of the recently released Chrome browser on mobile devices.
    • custom string — A custom string for the user agent.
    Default:
    latest-chrome-desktop
Examples:
  • Mimic the recent chrome on mobiles: setConverterUserAgent("latest-chrome-mobile")
  • Mimic Safari 18.0 browser: setConverterUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15")

API Client Options

public HtmlToImageClient setConverterVersion(string version)

Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.

Availability:
API client >= 5.0.0. See versioning.
Parameter:
  • version - The version identifier.
    Allowed Values:
    • 24.04 — Version 24.04.
    • 20.10 — Version 20.10.
    • 18.10 — Version 18.10.
    • latest — Version 20.10 is used.
    Default:
    24.04

public HtmlToImageClient setUseHttp(bool value)

Specify whether to use HTTP or HTTPS when connecting to the PDFCrowd API.

Parameter:
  • value (bool) - Set to true to use HTTP.
    Default:
    false

public HtmlToImageClient setClientUserAgent(string agent)

Specify the User-Agent HTTP header that the client library will use when interacting with the API.

Availability:
API client >= 6.4.0 See versioning.
Parameter:
  • agent - The user agent string.

public HtmlToImageClient setUserAgent(string agent)

Deprecated Replaced with: setClientUserAgent

Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.

Parameter:
  • agent - The user agent string.
    Default:
    pdfcrowd_dotnet_client/6.5.4 (https://pdfcrowd.com)

public HtmlToImageClient setProxy(string host, int port, string userName, string password)

Specify an HTTP proxy that the API client library will use to connect to the internet.

Parameters:
  • host - The proxy hostname.
  • port (int) - The proxy port.
  • userName - The username.
  • password - The password.

public HtmlToImageClient setRetryCount(int count)

Specify the number of automatic retries when a 502 or 503 HTTP status code is received. The status code indicates a temporary network issue. This feature can be disabled by setting to 0.

Parameter:
  • count (int) - Number of retries.
    Default:
    1
Example:
  • Retry failed requests three times: setRetryCount(3)