Constructor and Description |
---|
HtmlToPdfClient(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 |
getPageCount()
Get the total number of pages in the output document.
|
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 |
setEncrypt(boolean encrypt)
Encrypt the PDF.
|
void |
setExcludeFooterOnPages(String pages)
The page footer is not printed on the specified pages.
|
void |
setExcludeHeaderOnPages(String pages)
The page header is not printed on the specified pages.
|
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 |
setFooterHeight(String footerHeight)
Set the footer height.
|
void |
setFooterHtml(String footerHtml)
Use the specified HTML as the page footer.
|
void |
setFooterUrl(String footerUrl)
Load an HTML code from the specified URL and use it as the page footer.
|
void |
setHeaderFooterScaleFactor(int headerFooterScaleFactor)
Set the scaling factor (zoom) for the header and footer.
|
void |
setHeaderHeight(String headerHeight)
Set the header height.
|
void |
setHeaderHtml(String headerHtml)
Use the specified HTML code as the page header.
|
void |
setHeaderUrl(String headerUrl)
Load an HTML code from the specified URL and use it as the page header.
|
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 |
setLinearize(boolean linearize)
Create linearized PDF.
|
void |
setMarginBottom(String marginBottom)
Set the output page bottom margin.
|
void |
setMarginLeft(String marginLeft)
Set the output page left margin.
|
void |
setMarginRight(String marginRight)
Set the output page right margin.
|
void |
setMarginTop(String marginTop)
Set the output page top margin.
|
void |
setMultipageBackground(String multipageBackground)
Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
void |
setMultipageWatermark(String multipageWatermark)
Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
void |
setNoBackground(boolean noBackground)
Do not print the background graphics.
|
void |
setNoCopy(boolean noCopy)
Disallow text and graphics extraction from the output PDF.
|
void |
setNoMargins(boolean noMargins)
Disable margins.
|
void |
setNoModify(boolean noModify)
Disallow modification of the ouput PDF.
|
void |
setNoPrint(boolean noPrint)
Disallow printing of the output PDF.
|
void |
setNoXpdfcrowdHeader(boolean noXpdfcrowdHeader)
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
void |
setOrientation(String orientation)
Set the output page orientation.
|
void |
setOwnerPassword(String ownerPassword)
Protect the PDF with an owner password.
|
void |
setPageBackground(String pageBackground)
Apply the first page of the specified PDF to the background of every page of the output PDF.
|
void |
setPageDimensions(String width,
String height)
Set the output page dimensions.
|
void |
setPageHeight(String pageHeight)
Set the output page height.
|
void |
setPageMargins(String top,
String right,
String bottom,
String left)
Set the output page margins.
|
void |
setPageNumberingOffset(int offset)
Set an offset between physical and logical page numbers.
|
void |
setPageSize(String pageSize)
Set the output page size.
|
void |
setPageWatermark(String pageWatermark)
Apply the first page of the watermark PDF to every page of the output PDF.
|
void |
setPageWidth(String pageWidth)
Set the output page width.
|
void |
setPrintPageRange(String pages)
Set the page range to print.
|
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 |
setRenderingMode(String renderingMode)
Sets the rendering mode.
|
void |
setScaleFactor(int scaleFactor)
Set the scaling factor (zoom) for the main page area.
|
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 |
setUserPassword(String userPassword)
Protect the PDF with a user password.
|
void |
setVerifySslCertificates(boolean verifySslCertificates)
Do not allow insecure HTTPS connections.
|
void |
setViewport(int width,
int height)
Set the viewport size.
|
void |
setViewportHeight(int viewportHeight)
Set the viewport height in pixels.
|
void |
setViewportWidth(int viewportWidth)
Set the viewport width in pixels.
|
void |
setWaitForElement(String selectors)
Wait for the specified element in a source document.
|
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 setPageSize(String pageSize)
pageSize
- Allowed values are A2, A3, A4, A5, A6, Letter.public void setPageWidth(String pageWidth)
pageWidth
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setPageHeight(String pageHeight)
pageHeight
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setPageDimensions(String width, String height)
width
- Set the output page width. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).height
- Set the output page height. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setOrientation(String orientation)
orientation
- Allowed values are landscape, portrait.public void setMarginTop(String marginTop)
marginTop
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setMarginRight(String marginRight)
marginRight
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setMarginBottom(String marginBottom)
marginBottom
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setMarginLeft(String marginLeft)
marginLeft
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setNoMargins(boolean noMargins)
noMargins
- Set to true to disable margins.public void setPageMargins(String top, String right, String bottom, String left)
top
- Set the output page top margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).right
- Set the output page right margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).bottom
- Set the output page bottom margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).left
- Set the output page left margin. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setHeaderUrl(String headerUrl)
headerUrl
- The supported protocols are http:// and https://.public void setHeaderHtml(String headerHtml)
headerHtml
- The string must not be empty.public void setHeaderHeight(String headerHeight)
headerHeight
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setFooterUrl(String footerUrl)
footerUrl
- The supported protocols are http:// and https://.public void setFooterHtml(String footerHtml)
footerHtml
- The string must not be empty.public void setFooterHeight(String footerHeight)
footerHeight
- Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).public void setPrintPageRange(String pages)
pages
- A comma seperated list of page numbers or ranges.public void setPageWatermark(String pageWatermark)
pageWatermark
- The file path to a local watermark PDF file. The file must exist and not be empty.public void setMultipageWatermark(String multipageWatermark)
multipageWatermark
- The file path to a local watermark PDF file. The file must exist and not be empty.public void setPageBackground(String pageBackground)
pageBackground
- The file path to a local background PDF file. The file must exist and not be empty.public void setMultipageBackground(String multipageBackground)
multipageBackground
- The file path to a local background PDF file. The file must exist and not be empty.public void setExcludeHeaderOnPages(String pages)
pages
- List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma seperated list of page numbers.public void setExcludeFooterOnPages(String pages)
pages
- List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma seperated list of page numbers.public void setPageNumberingOffset(int offset)
offset
- Integer specifying page offset.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 setViewportWidth(int viewportWidth)
viewportWidth
- The value must be in a range 96-7680.public void setViewportHeight(int viewportHeight)
viewportHeight
- Must be a positive integer number.public void setViewport(int width, int height)
width
- Set the viewport width in pixels. The viewport is the user's visible area of the page. The value must be in a range 96-7680.height
- Set the viewport height in pixels. The viewport is the user's visible area of the page. Must be a positive integer number.public void setRenderingMode(String renderingMode)
renderingMode
- The rendering mode. Allowed values are default, viewport.public void setScaleFactor(int scaleFactor)
scaleFactor
- The scale factor. The value must be in a range 10-500.public void setHeaderFooterScaleFactor(int headerFooterScaleFactor)
headerFooterScaleFactor
- The scale factor. The value must be in a range 10-500.public void setLinearize(boolean linearize)
linearize
- Set to true to create linearized PDF.public void setEncrypt(boolean encrypt)
encrypt
- Set to true to enable PDF encryption.public void setUserPassword(String userPassword)
userPassword
- The user password.public void setOwnerPassword(String ownerPassword)
ownerPassword
- The owner password.public void setNoPrint(boolean noPrint)
noPrint
- Set to true to set the no-print flag in the output PDF.public void setNoModify(boolean noModify)
noModify
- Set to true to set the read-only only flag in the output PDF.public void setNoCopy(boolean noCopy)
noCopy
- Set to true to set the no-copy flag in the output PDF.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 getPageCount()
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.