public static final class Pdfcrowd.HtmlToImageClient
extends java.lang.Object
Constructor and Description |
---|
HtmlToImageClient(java.lang.String userName,
java.lang.String apiKey)
Constructor for the Pdfcrowd API client.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
convertFile(java.lang.String file)
Convert a local file.
|
void |
convertFileToFile(java.lang.String file,
java.lang.String filePath)
Convert a local file and write the result to a local file.
|
void |
convertFileToStream(java.lang.String file,
java.io.OutputStream outStream)
Convert a local file and write the result to an output stream.
|
byte[] |
convertString(java.lang.String text)
Convert a string.
|
void |
convertStringToFile(java.lang.String text,
java.lang.String filePath)
Convert a string and write the output to a file.
|
void |
convertStringToStream(java.lang.String text,
java.io.OutputStream outStream)
Convert a string and write the output to an output stream.
|
byte[] |
convertUrl(java.lang.String url)
Convert a web page.
|
void |
convertUrlToFile(java.lang.String url,
java.lang.String filePath)
Convert a web page and write the result to a local file.
|
void |
convertUrlToStream(java.lang.String url,
java.io.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.
|
java.lang.String |
getDebugLogUrl()
Get the URL of the debug log for the last conversion.
|
java.lang.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.
|
Pdfcrowd.HtmlToImageClient |
setBlockAds(boolean blockAds)
Try to block ads.
|
Pdfcrowd.HtmlToImageClient |
setClientCertificate(java.lang.String clientCertificate)
A client certificate to authenticate Pdfcrowd converter on your web server.
|
Pdfcrowd.HtmlToImageClient |
setClientCertificatePassword(java.lang.String clientCertificatePassword)
A password for PKCS12 file with a client certificate if it is needed.
|
Pdfcrowd.HtmlToImageClient |
setCookies(java.lang.String cookies)
Set cookies that are sent in Pdfcrowd HTTP requests.
|
Pdfcrowd.HtmlToImageClient |
setCustomHttpHeader(java.lang.String customHttpHeader)
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
Pdfcrowd.HtmlToImageClient |
setCustomJavascript(java.lang.String customJavascript)
Run a custom JavaScript after the document is loaded and ready to print.
|
Pdfcrowd.HtmlToImageClient |
setDataAutoEscape(boolean dataAutoEscape)
Auto escape HTML symbols in the input data before placing them into the output.
|
Pdfcrowd.HtmlToImageClient |
setDataEncoding(java.lang.String dataEncoding)
Set the encoding of the data file set by setDataFile.
|
Pdfcrowd.HtmlToImageClient |
setDataFile(java.lang.String dataFile)
Load the input data for template rendering from the specified file.
|
Pdfcrowd.HtmlToImageClient |
setDataFormat(java.lang.String dataFormat)
Specify the input data format.
|
Pdfcrowd.HtmlToImageClient |
setDataIgnoreUndefined(boolean dataIgnoreUndefined)
Ignore undefined variables in the HTML template.
|
Pdfcrowd.HtmlToImageClient |
setDataOptions(java.lang.String dataOptions)
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(java.lang.String dataString)
Set the input data for template rendering.
|
Pdfcrowd.HtmlToImageClient |
setDataTrimBlocks(boolean dataTrimBlocks)
Auto trim whitespace around each template command block.
|
Pdfcrowd.HtmlToImageClient |
setDebugLog(boolean debugLog)
Turn on the debug logging.
|
Pdfcrowd.HtmlToImageClient |
setDefaultEncoding(java.lang.String defaultEncoding)
Set the default HTML content text encoding.
|
Pdfcrowd.HtmlToImageClient |
setDisableImageLoading(boolean disableImageLoading)
Do not load images.
|
Pdfcrowd.HtmlToImageClient |
setDisableJavascript(boolean disableJavascript)
Do not execute JavaScript.
|
Pdfcrowd.HtmlToImageClient |
setDisableRemoteFonts(boolean disableRemoteFonts)
Disable loading fonts from remote sources.
|
Pdfcrowd.HtmlToImageClient |
setElementToConvert(java.lang.String selectors)
Convert only the specified element from the main document and its children.
|
Pdfcrowd.HtmlToImageClient |
setElementToConvertMode(java.lang.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(java.lang.String userName,
java.lang.String password)
Set credentials to access HTTP base authentication protected websites.
|
Pdfcrowd.HtmlToImageClient |
setHttpAuthPassword(java.lang.String password)
Set the HTTP authentication password.
|
Pdfcrowd.HtmlToImageClient |
setHttpAuthUserName(java.lang.String userName)
Set the HTTP authentication user name.
|
Pdfcrowd.HtmlToImageClient |
setHttpProxy(java.lang.String httpProxy)
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme.
|
Pdfcrowd.HtmlToImageClient |
setHttpsProxy(java.lang.String httpsProxy)
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme.
|
Pdfcrowd.HtmlToImageClient |
setJavascriptDelay(int javascriptDelay)
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
Pdfcrowd.HtmlToImageClient |
setNoBackground(boolean noBackground)
Do not print the background graphics.
|
Pdfcrowd.HtmlToImageClient |
setNoXpdfcrowdHeader(boolean noXpdfcrowdHeader)
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
Pdfcrowd.HtmlToImageClient |
setOnLoadJavascript(java.lang.String onLoadJavascript)
Run a custom JavaScript right after the document is loaded.
|
Pdfcrowd.HtmlToImageClient |
setOutputFormat(java.lang.String outputFormat)
The format of the output file.
|
Pdfcrowd.HtmlToImageClient |
setProxy(java.lang.String host,
int port,
java.lang.String userName,
java.lang.String password)
Specifies an HTTP proxy that the API client library will use to connect to the internet.
|
Pdfcrowd.HtmlToImageClient |
setRetryCount(int retryCount)
Specifies the number of retries when the 502 HTTP status code is received.
|
Pdfcrowd.HtmlToImageClient |
setScaleFactor(int scaleFactor)
Set the scaling factor (zoom) for the output image.
|
Pdfcrowd.HtmlToImageClient |
setScreenshotHeight(int screenshotHeight)
Set the output image height in pixels.
|
Pdfcrowd.HtmlToImageClient |
setScreenshotWidth(int screenshotWidth)
Set the output image width in pixels.
|
Pdfcrowd.HtmlToImageClient |
setTag(java.lang.String tag)
Tag the conversion with a custom value.
|
Pdfcrowd.HtmlToImageClient |
setUseHttp(boolean useHttp)
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
Pdfcrowd.HtmlToImageClient |
setUsePrintMedia(boolean usePrintMedia)
Use the print version of the page if available (@media print).
|
Pdfcrowd.HtmlToImageClient |
setUserAgent(java.lang.String userAgent)
Set a custom user agent HTTP header.
|
Pdfcrowd.HtmlToImageClient |
setVerifySslCertificates(boolean verifySslCertificates)
Do not allow insecure HTTPS connections.
|
Pdfcrowd.HtmlToImageClient |
setWaitForElement(java.lang.String selectors)
Wait for the specified element in a source document.
|
public HtmlToImageClient(java.lang.String userName, java.lang.String apiKey)
userName
- Your username at Pdfcrowd.apiKey
- Your API key.public Pdfcrowd.HtmlToImageClient setOutputFormat(java.lang.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(java.lang.String url)
url
- The address of the web page to convert. The supported protocols are http:// and https://.public void convertUrlToStream(java.lang.String url, java.io.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(java.lang.String url, java.lang.String filePath) throws java.io.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.java.io.IOException
public byte[] convertFile(java.lang.String file)
file
- The path to a local file to convert.public void convertFileToStream(java.lang.String file, java.io.OutputStream outStream)
file
- The path to a local file to convert.outStream
- The output stream that will contain the conversion output.public void convertFileToFile(java.lang.String file, java.lang.String filePath) throws java.io.IOException
file
- The path to a local file to convert.filePath
- The output file path. The string must not be empty.java.io.IOException
public byte[] convertString(java.lang.String text)
text
- The string content to convert. The string must not be empty.public void convertStringToStream(java.lang.String text, java.io.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(java.lang.String text, java.lang.String filePath) throws java.io.IOException
text
- The string content to convert. The string must not be empty.filePath
- The output file path. The string must not be empty.java.io.IOException
public Pdfcrowd.HtmlToImageClient setDataString(java.lang.String dataString)
dataString
- The input data string.public Pdfcrowd.HtmlToImageClient setDataFile(java.lang.String dataFile)
dataFile
- The file path to a local file containing the input data.public Pdfcrowd.HtmlToImageClient setDataFormat(java.lang.String dataFormat)
dataFormat
- The data format. Allowed values are auto, json, xml, yaml, csv.public Pdfcrowd.HtmlToImageClient setDataEncoding(java.lang.String dataEncoding)
dataEncoding
- The data file encoding.public Pdfcrowd.HtmlToImageClient setDataIgnoreUndefined(boolean dataIgnoreUndefined)
dataIgnoreUndefined
- Set to true to ignore undefined variables.public Pdfcrowd.HtmlToImageClient setDataAutoEscape(boolean dataAutoEscape)
dataAutoEscape
- Set to true to turn auto escaping on.public Pdfcrowd.HtmlToImageClient setDataTrimBlocks(boolean dataTrimBlocks)
dataTrimBlocks
- Set to true to turn auto trimming on.public Pdfcrowd.HtmlToImageClient setDataOptions(java.lang.String dataOptions)
dataOptions
- Comma separated list of options.public Pdfcrowd.HtmlToImageClient setNoBackground(boolean noBackground)
noBackground
- Set to true to disable the background graphics.public Pdfcrowd.HtmlToImageClient setDisableJavascript(boolean disableJavascript)
disableJavascript
- Set to true to disable JavaScript in web pages.public Pdfcrowd.HtmlToImageClient setDisableImageLoading(boolean disableImageLoading)
disableImageLoading
- Set to true to disable loading of images.public Pdfcrowd.HtmlToImageClient setDisableRemoteFonts(boolean disableRemoteFonts)
disableRemoteFonts
- Set to true disable loading remote fonts.public Pdfcrowd.HtmlToImageClient setBlockAds(boolean blockAds)
blockAds
- Set to true to block ads in web pages.public Pdfcrowd.HtmlToImageClient setDefaultEncoding(java.lang.String defaultEncoding)
defaultEncoding
- The text encoding of the HTML content.public Pdfcrowd.HtmlToImageClient setHttpAuthUserName(java.lang.String userName)
userName
- The user name.public Pdfcrowd.HtmlToImageClient setHttpAuthPassword(java.lang.String password)
password
- The password.public Pdfcrowd.HtmlToImageClient setHttpAuth(java.lang.String userName, java.lang.String password)
userName
- Set the HTTP authentication user name.password
- Set the HTTP authentication password.public Pdfcrowd.HtmlToImageClient setUsePrintMedia(boolean usePrintMedia)
usePrintMedia
- Set to true to use the print version of the page.public Pdfcrowd.HtmlToImageClient setNoXpdfcrowdHeader(boolean noXpdfcrowdHeader)
noXpdfcrowdHeader
- Set to true to disable sending X-Pdfcrowd HTTP header.public Pdfcrowd.HtmlToImageClient setCookies(java.lang.String cookies)
cookies
- The cookie string.public Pdfcrowd.HtmlToImageClient setVerifySslCertificates(boolean verifySslCertificates)
verifySslCertificates
- 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 setCustomJavascript(java.lang.String customJavascript)
customJavascript
- A string containing a JavaScript code. The string must not be empty.public Pdfcrowd.HtmlToImageClient setOnLoadJavascript(java.lang.String onLoadJavascript)
onLoadJavascript
- A string containing a JavaScript code. The string must not be empty.public Pdfcrowd.HtmlToImageClient setCustomHttpHeader(java.lang.String customHttpHeader)
customHttpHeader
- A string containing the header name and value separated by a colon.public Pdfcrowd.HtmlToImageClient setJavascriptDelay(int javascriptDelay)
javascriptDelay
- The number of milliseconds to wait. Must be a positive integer number or 0.public Pdfcrowd.HtmlToImageClient setElementToConvert(java.lang.String selectors)
selectors
- One or more CSS selectors separated by commas. The string must not be empty.public Pdfcrowd.HtmlToImageClient setElementToConvertMode(java.lang.String mode)
mode
- Allowed values are cut-out, remove-siblings, hide-siblings.public Pdfcrowd.HtmlToImageClient setWaitForElement(java.lang.String selectors)
selectors
- One or more CSS selectors separated by commas. The string must not be empty.public Pdfcrowd.HtmlToImageClient setScreenshotWidth(int screenshotWidth)
screenshotWidth
- The value must be in the range 96-65000.public Pdfcrowd.HtmlToImageClient setScreenshotHeight(int screenshotHeight)
screenshotHeight
- Must be a positive integer number.public Pdfcrowd.HtmlToImageClient setScaleFactor(int scaleFactor)
scaleFactor
- The percentage value. Must be a positive integer number.public Pdfcrowd.HtmlToImageClient setDebugLog(boolean debugLog)
debugLog
- Set to true to enable the debug logging.public java.lang.String getDebugLogUrl()
public int getRemainingCreditCount()
public int getConsumedCreditCount()
public java.lang.String getJobId()
public int getOutputSize()
public Pdfcrowd.HtmlToImageClient setTag(java.lang.String tag)
tag
- A string with the custom tag.public Pdfcrowd.HtmlToImageClient setHttpProxy(java.lang.String httpProxy)
httpProxy
- The value must have format DOMAIN_OR_IP_ADDRESS:PORT.public Pdfcrowd.HtmlToImageClient setHttpsProxy(java.lang.String httpsProxy)
httpsProxy
- The value must have format DOMAIN_OR_IP_ADDRESS:PORT.public Pdfcrowd.HtmlToImageClient setClientCertificate(java.lang.String clientCertificate)
clientCertificate
- The file must be in PKCS12 format. The file must exist and not be empty.public Pdfcrowd.HtmlToImageClient setClientCertificatePassword(java.lang.String clientCertificatePassword)
clientCertificatePassword
- public Pdfcrowd.HtmlToImageClient setUseHttp(boolean useHttp)
useHttp
- Set to true to use HTTP.public Pdfcrowd.HtmlToImageClient setUserAgent(java.lang.String userAgent)
userAgent
- The user agent string.public Pdfcrowd.HtmlToImageClient setProxy(java.lang.String host, int port, java.lang.String userName, java.lang.String password)
host
- The proxy hostname.port
- The proxy port.userName
- The username.password
- The password.public Pdfcrowd.HtmlToImageClient setRetryCount(int retryCount)
retryCount
- Number of retries wanted.Copyright © 2020. All rights reserved.