Constructor and Description |
---|
HtmlToImageClient(String userName,
String apiKey)
Constructor for the Pdfcrowd API client.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
convertFile(String file)
Convert a local file.
|
void |
convertFileToFile(String file,
String filePath)
Convert a local file and write the result to a local file.
|
void |
convertFileToStream(String file,
OutputStream outStream)
Convert a local file and write the result to an output stream.
|
byte[] |
convertStream(InputStream inStream)
Convert the contents of an input stream.
|
void |
convertStreamToFile(InputStream inStream,
String filePath)
Convert the contents of an input stream and write the result to a local file.
|
void |
convertStreamToStream(InputStream inStream,
OutputStream outStream)
Convert the contents of an input stream and write the result to an output stream.
|
byte[] |
convertString(String text)
Convert a string.
|
void |
convertStringToFile(String text,
String filePath)
Convert a string and write the output to a file.
|
void |
convertStringToStream(String text,
OutputStream outStream)
Convert a string and write the output to an output stream.
|
byte[] |
convertUrl(String url)
Convert a web page.
|
void |
convertUrlToFile(String url,
String filePath)
Convert a web page and write the result to a local file.
|
void |
convertUrlToStream(String url,
OutputStream outStream)
Convert a web page and write the result to an output stream.
|
int |
getConsumedCreditCount()
Get the number of credits consumed by the last conversion.
|
String |
getDebugLogUrl()
Get the URL of the debug log for the last conversion.
|
String |
getJobId()
Get the job id.
|
int |
getOutputSize()
Get the size of the output in bytes.
|
int |
getRemainingCreditCount()
Get the number of conversion credits available in your account.
|
String |
getVersion()
Get the version details.
|
Pdfcrowd.HtmlToImageClient |
setAutoDetectElementToConvert(boolean value)
The main HTML element for conversion is detected automatically.
|
Pdfcrowd.HtmlToImageClient |
setBackgroundColor(String color)
The output image background color.
|
Pdfcrowd.HtmlToImageClient |
setBlockAds(boolean value)
Try to block ads.
|
Pdfcrowd.HtmlToImageClient |
setClientCertificate(String certificate)
A client certificate to authenticate Pdfcrowd converter on your web server.
|
Pdfcrowd.HtmlToImageClient |
setClientCertificatePassword(String password)
A password for PKCS12 file with a client certificate if it is needed.
|
Pdfcrowd.HtmlToImageClient |
setConverterVersion(String version)
Set the converter version.
|
Pdfcrowd.HtmlToImageClient |
setCookies(String cookies)
Set cookies that are sent in Pdfcrowd HTTP requests.
|
Pdfcrowd.HtmlToImageClient |
setCustomHttpHeader(String header)
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
Pdfcrowd.HtmlToImageClient |
setCustomJavascript(String javascript)
Run a custom JavaScript after the document is loaded and ready to print.
|
Pdfcrowd.HtmlToImageClient |
setDataAutoEscape(boolean value)
Auto escape HTML symbols in the input data before placing them into the output.
|
Pdfcrowd.HtmlToImageClient |
setDataEncoding(String encoding)
Set the encoding of the data file set by setDataFile.
|
Pdfcrowd.HtmlToImageClient |
setDataFile(String dataFile)
Load the input data for template rendering from the specified file.
|
Pdfcrowd.HtmlToImageClient |
setDataFormat(String dataFormat)
Specify the input data format.
|
Pdfcrowd.HtmlToImageClient |
setDataIgnoreUndefined(boolean value)
Ignore undefined variables in the HTML template.
|
Pdfcrowd.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.
|
Pdfcrowd.HtmlToImageClient |
setDataString(String dataString)
Set the input data for template rendering.
|
Pdfcrowd.HtmlToImageClient |
setDataTrimBlocks(boolean value)
Auto trim whitespace around each template command block.
|
Pdfcrowd.HtmlToImageClient |
setDebugLog(boolean value)
Turn on the debug logging.
|
Pdfcrowd.HtmlToImageClient |
setDefaultEncoding(String encoding)
Set the default HTML content text encoding.
|
Pdfcrowd.HtmlToImageClient |
setDisableImageLoading(boolean value)
Do not load images.
|
Pdfcrowd.HtmlToImageClient |
setDisableJavascript(boolean value)
Do not execute JavaScript.
|
Pdfcrowd.HtmlToImageClient |
setDisableRemoteFonts(boolean value)
Disable loading fonts from remote sources.
|
Pdfcrowd.HtmlToImageClient |
setElementToConvert(String selectors)
Convert only the specified element from the main document and its children.
|
Pdfcrowd.HtmlToImageClient |
setElementToConvertMode(String mode)
Specify the DOM handling when only a part of the document is converted.
|
Pdfcrowd.HtmlToImageClient |
setFailOnAnyUrlError(boolean failOnError)
Abort the conversion if any of the sub-request HTTP status code is greater than or equal to 400 or if some sub-requests are still pending.
|
Pdfcrowd.HtmlToImageClient |
setFailOnMainUrlError(boolean failOnError)
Abort the conversion if the main URL HTTP status code is greater than or equal to 400.
|
Pdfcrowd.HtmlToImageClient |
setHttpAuth(String userName,
String password)
Set credentials to access HTTP base authentication protected websites.
|
Pdfcrowd.HtmlToImageClient |
setHttpAuthPassword(String password)
Set the HTTP authentication password.
|
Pdfcrowd.HtmlToImageClient |
setHttpAuthUserName(String userName)
Set the HTTP authentication user name.
|
Pdfcrowd.HtmlToImageClient |
setHttpProxy(String proxy)
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme.
|
Pdfcrowd.HtmlToImageClient |
setHttpsProxy(String proxy)
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme.
|
Pdfcrowd.HtmlToImageClient |
setJavascriptDelay(int delay)
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
Pdfcrowd.HtmlToImageClient |
setLoadIframes(String iframes)
Specifies how iframes are handled.
|
Pdfcrowd.HtmlToImageClient |
setLocale(String locale)
Set the locale for the conversion.
|
Pdfcrowd.HtmlToImageClient |
setNoBackground(boolean value)
Do not print the background graphics.
|
Pdfcrowd.HtmlToImageClient |
setNoXpdfcrowdHeader(boolean value)
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
Pdfcrowd.HtmlToImageClient |
setOnLoadJavascript(String javascript)
Run a custom JavaScript right after the document is loaded.
|
Pdfcrowd.HtmlToImageClient |
setOutputFormat(String outputFormat)
The format of the output file.
|
Pdfcrowd.HtmlToImageClient |
setProxy(String host,
int port,
String userName,
String password)
Specifies an HTTP proxy that the API client library will use to connect to the internet.
|
Pdfcrowd.HtmlToImageClient |
setReadabilityEnhancements(String enhancements)
The input HTML is automatically enhanced to improve the readability.
|
Pdfcrowd.HtmlToImageClient |
setRetryCount(int count)
Specifies the number of automatic retries when the 502 or 503 HTTP status code is received.
|
Pdfcrowd.HtmlToImageClient |
setScaleFactor(int factor)
Set the scaling factor (zoom) for the output image.
|
Pdfcrowd.HtmlToImageClient |
setScreenshotHeight(int height)
Set the output image height in pixels.
|
Pdfcrowd.HtmlToImageClient |
setScreenshotWidth(int width)
Set the output image width in pixels.
|
Pdfcrowd.HtmlToImageClient |
setTag(String tag)
Tag the conversion with a custom value.
|
Pdfcrowd.HtmlToImageClient |
setUseHttp(boolean value)
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
Pdfcrowd.HtmlToImageClient |
setUseMobileUserAgent(boolean value)
Use a mobile user agent.
|
Pdfcrowd.HtmlToImageClient |
setUsePrintMedia(boolean value)
Use the print version of the page if available (@media print).
|
Pdfcrowd.HtmlToImageClient |
setUserAgent(String agent)
Set a custom user agent HTTP header.
|
Pdfcrowd.HtmlToImageClient |
setVerifySslCertificates(boolean value)
Do not allow insecure HTTPS connections.
|
Pdfcrowd.HtmlToImageClient |
setWaitForElement(String selectors)
Wait for the specified element in a source document.
|
Pdfcrowd.HtmlToImageClient |
setZipMainFilename(String filename)
Set the file name of the main HTML document stored in the input archive.
|
public Pdfcrowd.HtmlToImageClient setOutputFormat(String outputFormat)
outputFormat
- Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.public byte[] convertUrl(String url)
url
- The address of the web page to convert. The supported protocols are http:// and https://.public void convertUrlToStream(String url, OutputStream outStream)
url
- The address of the web page to convert. The supported protocols are http:// and https://.outStream
- The output stream that will contain the conversion output.public void convertUrlToFile(String url, String filePath) throws IOException
url
- The address of the web page to convert. The supported protocols are http:// and https://.filePath
- The output file path. The string must not be empty.IOException
public byte[] convertFile(String file)
file
- The path to a local file to convert.public void convertFileToStream(String file, OutputStream outStream)
file
- The path to a local file to convert.outStream
- The output stream that will contain the conversion output.public void convertFileToFile(String file, String filePath) throws IOException
file
- The path to a local file to convert.filePath
- The output file path. The string must not be empty.IOException
public byte[] convertString(String text)
text
- The string content to convert. The string must not be empty.public void convertStringToStream(String text, OutputStream outStream)
text
- The string content to convert. The string must not be empty.outStream
- The output stream that will contain the conversion output.public void convertStringToFile(String text, String filePath) throws IOException
text
- The string content to convert. The string must not be empty.filePath
- The output file path. The string must not be empty.IOException
public byte[] convertStream(InputStream inStream) throws IOException
inStream
- The input stream with source data.IOException
public void convertStreamToStream(InputStream inStream, OutputStream outStream) throws IOException
inStream
- The input stream with source data.outStream
- The output stream that will contain the conversion output.IOException
public void convertStreamToFile(InputStream inStream, String filePath) throws IOException
inStream
- The input stream with source data.filePath
- The output file path. The string must not be empty.IOException
public Pdfcrowd.HtmlToImageClient setZipMainFilename(String filename)
filename
- The file name.public Pdfcrowd.HtmlToImageClient setUsePrintMedia(boolean value)
value
- Set to true to use the print version of the page.public Pdfcrowd.HtmlToImageClient setNoBackground(boolean value)
value
- Set to true to disable the background graphics.public Pdfcrowd.HtmlToImageClient setDisableJavascript(boolean value)
value
- Set to true to disable JavaScript in web pages.public Pdfcrowd.HtmlToImageClient setDisableImageLoading(boolean value)
value
- Set to true to disable loading of images.public Pdfcrowd.HtmlToImageClient setDisableRemoteFonts(boolean value)
value
- Set to true disable loading remote fonts.public Pdfcrowd.HtmlToImageClient setUseMobileUserAgent(boolean value)
value
- Set to true to use a mobile user agent.public Pdfcrowd.HtmlToImageClient setLoadIframes(String iframes)
iframes
- Allowed values are all, same-origin, none.public Pdfcrowd.HtmlToImageClient setBlockAds(boolean value)
value
- Set to true to block ads in web pages.public Pdfcrowd.HtmlToImageClient setDefaultEncoding(String encoding)
encoding
- The text encoding of the HTML content.public Pdfcrowd.HtmlToImageClient setLocale(String locale)
locale
- The locale code according to ISO 639.public Pdfcrowd.HtmlToImageClient setHttpAuthUserName(String userName)
userName
- The user name.public Pdfcrowd.HtmlToImageClient setHttpAuthPassword(String password)
password
- The password.public Pdfcrowd.HtmlToImageClient setHttpAuth(String userName, String password)
userName
- Set the HTTP authentication user name.password
- Set the HTTP authentication password.public Pdfcrowd.HtmlToImageClient setCookies(String cookies)
cookies
- The cookie string.public Pdfcrowd.HtmlToImageClient setVerifySslCertificates(boolean value)
value
- Set to true to enable SSL certificate verification.public Pdfcrowd.HtmlToImageClient setFailOnMainUrlError(boolean failOnError)
failOnError
- Set to true to abort the conversion.public Pdfcrowd.HtmlToImageClient setFailOnAnyUrlError(boolean failOnError)
failOnError
- Set to true to abort the conversion.public Pdfcrowd.HtmlToImageClient setNoXpdfcrowdHeader(boolean value)
value
- Set to true to disable sending X-Pdfcrowd HTTP header.public Pdfcrowd.HtmlToImageClient setCustomJavascript(String javascript)
javascript
- A string containing a JavaScript code. The string must not be empty.public Pdfcrowd.HtmlToImageClient setOnLoadJavascript(String javascript)
javascript
- A string containing a JavaScript code. The string must not be empty.public Pdfcrowd.HtmlToImageClient setCustomHttpHeader(String header)
header
- A string containing the header name and value separated by a colon.public Pdfcrowd.HtmlToImageClient setJavascriptDelay(int delay)
delay
- The number of milliseconds to wait. Must be a positive integer number or 0.public Pdfcrowd.HtmlToImageClient setElementToConvert(String selectors)
selectors
- One or more CSS selectors separated by commas. The string must not be empty.public Pdfcrowd.HtmlToImageClient setElementToConvertMode(String mode)
mode
- Allowed values are cut-out, remove-siblings, hide-siblings.public Pdfcrowd.HtmlToImageClient setWaitForElement(String selectors)
selectors
- One or more CSS selectors separated by commas. The string must not be empty.public Pdfcrowd.HtmlToImageClient setAutoDetectElementToConvert(boolean value)
value
- Set to true to detect the main element.public Pdfcrowd.HtmlToImageClient setReadabilityEnhancements(String enhancements)
enhancements
- Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.public Pdfcrowd.HtmlToImageClient setScreenshotWidth(int width)
width
- The value must be in the range 96-65000.public Pdfcrowd.HtmlToImageClient setScreenshotHeight(int height)
height
- Must be a positive integer number.public Pdfcrowd.HtmlToImageClient setScaleFactor(int factor)
factor
- The percentage value. Must be a positive integer number.public Pdfcrowd.HtmlToImageClient setBackgroundColor(String color)
color
- The value must be in RRGGBB or RRGGBBAA hexadecimal format.public Pdfcrowd.HtmlToImageClient setDataString(String dataString)
dataString
- The input data string.public Pdfcrowd.HtmlToImageClient setDataFile(String dataFile)
dataFile
- The file path to a local file containing the input data.public Pdfcrowd.HtmlToImageClient setDataFormat(String dataFormat)
dataFormat
- The data format. Allowed values are auto, json, xml, yaml, csv.public Pdfcrowd.HtmlToImageClient setDataEncoding(String encoding)
encoding
- The data file encoding.public Pdfcrowd.HtmlToImageClient setDataIgnoreUndefined(boolean value)
value
- Set to true to ignore undefined variables.public Pdfcrowd.HtmlToImageClient setDataAutoEscape(boolean value)
value
- Set to true to turn auto escaping on.public Pdfcrowd.HtmlToImageClient setDataTrimBlocks(boolean value)
value
- Set to true to turn auto trimming on.public Pdfcrowd.HtmlToImageClient setDataOptions(String options)
options
- Comma separated list of options.public Pdfcrowd.HtmlToImageClient setDebugLog(boolean value)
value
- Set to true to enable the debug logging.public String getDebugLogUrl()
public int getRemainingCreditCount()
public int getConsumedCreditCount()
public String getJobId()
public int getOutputSize()
public String getVersion()
public Pdfcrowd.HtmlToImageClient setTag(String tag)
tag
- A string with the custom tag.public Pdfcrowd.HtmlToImageClient setHttpProxy(String proxy)
proxy
- The value must have format DOMAIN_OR_IP_ADDRESS:PORT.public Pdfcrowd.HtmlToImageClient setHttpsProxy(String proxy)
proxy
- The value must have format DOMAIN_OR_IP_ADDRESS:PORT.public Pdfcrowd.HtmlToImageClient setClientCertificate(String certificate)
certificate
- The file must be in PKCS12 format. The file must exist and not be empty.public Pdfcrowd.HtmlToImageClient setClientCertificatePassword(String password)
password
- public Pdfcrowd.HtmlToImageClient setConverterVersion(String version)
version
- The version identifier. Allowed values are latest, 20.10, 18.10.public Pdfcrowd.HtmlToImageClient setUseHttp(boolean value)
value
- Set to true to use HTTP.public Pdfcrowd.HtmlToImageClient setUserAgent(String agent)
agent
- The user agent string.public Pdfcrowd.HtmlToImageClient setProxy(String host, int port, String userName, String password)
host
- The proxy hostname.port
- The proxy port.userName
- The username.password
- The password.public Pdfcrowd.HtmlToImageClient setRetryCount(int count)
count
- Number of retries.Copyright © 2023. All rights reserved.