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[] |
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.
|
void |
setCookies(String cookies)
Set cookies that are sent in Pdfcrowd HTTP requests.
|
void |
setCustomHttpHeader(String customHttpHeader)
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
void |
setCustomJavascript(String customJavascript)
Run a custom JavaScript after the document is loaded.
|
void |
setDebugLog(boolean debugLog)
Turn on the debug logging.
|
void |
setDefaultEncoding(String defaultEncoding)
Set the default HTML content text encoding.
|
void |
setDisableImageLoading(boolean disableImageLoading)
Do not load images.
|
void |
setDisableJavascript(boolean disableJavascript)
Do not execute JavaScript.
|
void |
setDisableRemoteFonts(boolean disableRemoteFonts)
Disable loading fonts from remote sources.
|
void |
setElementToConvert(String selectors)
Convert only the specified element and its children.
|
void |
setElementToConvertMode(String mode)
Specify the DOM handling when only a part of the document is converted.
|
void |
setFailOnAnyUrlError(boolean failOnError)
Abort the conversion if any of the sub-request HTTP status code is greater than or equal to 400.
|
void |
setFailOnMainUrlError(boolean failOnError)
Abort the conversion if the main URL HTTP status code is greater than or equal to 400.
|
void |
setHttpAuth(String userName,
String password)
Set the HTTP authentication.
|
void |
setHttpAuthPassword(String password)
Set the HTTP authentication password.
|
void |
setHttpAuthUserName(String userName)
Set the HTTP authentication user name.
|
void |
setJavascriptDelay(int javascriptDelay)
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
void |
setNoBackground(boolean noBackground)
Do not print the background graphics.
|
void |
setNoXpdfcrowdHeader(boolean noXpdfcrowdHeader)
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
void |
setOutputFormat(String outputFormat)
The format of the output file.
|
void |
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.
|
void |
setScreenshotHeight(int screenshotHeight)
Set the output image height in pixels.
|
void |
setScreenshotWidth(int screenshotWidth)
Set the output image width in pixels.
|
void |
setUseHttp(boolean useHttp)
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
void |
setUsePrintMedia(boolean usePrintMedia)
Use the print version of the page if available (@media print).
|
void |
setUserAgent(String userAgent)
Set a custom user agent HTTP header.
|
void |
setVerifySslCertificates(boolean verifySslCertificates)
Do not allow insecure HTTPS connections.
|
void |
setWaitForElement(String selectors)
Wait for the specified element in a source document.
|
public void 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 void setNoBackground(boolean noBackground)
noBackground
- Set to true to disable the background graphics.public void setDisableJavascript(boolean disableJavascript)
disableJavascript
- Set to true to disable JavaScript in web pages.public void setDisableImageLoading(boolean disableImageLoading)
disableImageLoading
- Set to true to disable loading of images.public void setDisableRemoteFonts(boolean disableRemoteFonts)
disableRemoteFonts
- Set to true disable loading remote fonts.public void setDefaultEncoding(String defaultEncoding)
defaultEncoding
- The text encoding of the HTML content.public void setHttpAuthUserName(String userName)
userName
- The user name.public void setHttpAuthPassword(String password)
password
- The password.public void setHttpAuth(String userName, String password)
userName
- Set the HTTP authentication user name.password
- Set the HTTP authentication password.public void setUsePrintMedia(boolean usePrintMedia)
usePrintMedia
- Set to true to use the print version of the page.public void setNoXpdfcrowdHeader(boolean noXpdfcrowdHeader)
noXpdfcrowdHeader
- Set to true to disable sending X-Pdfcrowd HTTP header.public void setCookies(String cookies)
cookies
- The cookie string.public void setVerifySslCertificates(boolean verifySslCertificates)
verifySslCertificates
- Set to true to enable SSL certificate verification.public void setFailOnMainUrlError(boolean failOnError)
failOnError
- Set to true to abort the conversion.public void setFailOnAnyUrlError(boolean failOnError)
failOnError
- Set to true to abort the conversion.public void setCustomJavascript(String customJavascript)
customJavascript
- String containing a JavaScript code. The string must not be empty.public void setCustomHttpHeader(String customHttpHeader)
customHttpHeader
- A string containing the header name and value separated by a colon.public void setJavascriptDelay(int javascriptDelay)
javascriptDelay
- The number of milliseconds to wait. Must be a positive integer number or 0.public void setElementToConvert(String selectors)
selectors
- One or more CSS selectors separated by commas. The string must not be empty.public void setElementToConvertMode(String mode)
mode
- Allowed values are cut-out, remove-siblings, hide-siblings.public void setWaitForElement(String selectors)
selectors
- One or more CSS selectors separated by commas. The string must not be empty.public void setScreenshotWidth(int screenshotWidth)
screenshotWidth
- The value must be in a range 96-7680.public void setScreenshotHeight(int screenshotHeight)
screenshotHeight
- Must be a positive integer number.public void setDebugLog(boolean debugLog)
debugLog
- Set to true to enable the debug logging.public String getDebugLogUrl()
public int getRemainingCreditCount()
public int getConsumedCreditCount()
public String getJobId()
public int getOutputSize()
public void setUseHttp(boolean useHttp)
useHttp
- Set to true to use HTTP.public void setUserAgent(String userAgent)
userAgent
- The user agent string.Copyright © 2017. All rights reserved.