pdfcrowd

package module
v0.0.0-...-6e9d7da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 13 Imported by: 5

README

Pdfcrowd API - Go client library

The Pdfcrowd API lets you easily convert between HTML, PDF and various image formats in your Go applications.

To use the API, you need an account on http://pdfcrowd.com. If you don't have one, you can sign up here.

Installation

To install via Go language:

$ go get github.com/pdfcrowd/pdfcrowd-go

Learn more

License

This client library is licensed under the MIT License.

Documentation

Index

Constants

View Source
const CLIENT_VERSION = "6.4.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() string

func (Error) GetCode

func (e Error) GetCode() int

func (Error) GetMessage

func (e Error) GetMessage() string

type HtmlToImageClient

type HtmlToImageClient struct {
	// contains filtered or unexported fields
}

Conversion from HTML to image.

func NewHtmlToImageClient

func NewHtmlToImageClient(userName string, apiKey string) HtmlToImageClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*HtmlToImageClient) ConvertFile

func (client *HtmlToImageClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

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. The file must exist and not be empty. The file name must have a valid extension.

func (*HtmlToImageClient) ConvertFileToFile

func (client *HtmlToImageClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

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. The file must exist and not be empty. The file name must have a valid extension. filePath - The output file path. The string must not be empty.

func (*HtmlToImageClient) ConvertFileToStream

func (client *HtmlToImageClient) ConvertFileToStream(file string, outStream io.Writer) error

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

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. The file must exist and not be empty. The file name must have a valid extension. outStream - The output stream that will contain the conversion output.

func (*HtmlToImageClient) ConvertStream

func (client *HtmlToImageClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - 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).

func (*HtmlToImageClient) ConvertStreamToFile

func (client *HtmlToImageClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - 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. The string must not be empty.

func (*HtmlToImageClient) ConvertStreamToStream

func (client *HtmlToImageClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - 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 - The output stream that will contain the conversion output.

func (*HtmlToImageClient) ConvertString

func (client *HtmlToImageClient) ConvertString(text string) ([]byte, error)

Convert a string.

text - The string content to convert. The string must not be empty.

func (*HtmlToImageClient) ConvertStringToFile

func (client *HtmlToImageClient) ConvertStringToFile(text string, filePath string) error

Convert a string and write the output to a file.

text - The string content to convert. The string must not be empty. filePath - The output file path. The string must not be empty.

func (*HtmlToImageClient) ConvertStringToStream

func (client *HtmlToImageClient) ConvertStringToStream(text string, outStream io.Writer) error

Convert a string and write the output to an output stream.

text - The string content to convert. The string must not be empty. outStream - The output stream that will contain the conversion output.

func (*HtmlToImageClient) ConvertUrl

func (client *HtmlToImageClient) ConvertUrl(url string) ([]byte, error)

Convert a web page.

url - The address of the web page to convert. The supported protocols are http:// and https://.

func (*HtmlToImageClient) ConvertUrlToFile

func (client *HtmlToImageClient) ConvertUrlToFile(url string, filePath string) error

Convert a web page and write the result to a local file.

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.

func (*HtmlToImageClient) ConvertUrlToStream

func (client *HtmlToImageClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert a web page and write the result to an output stream.

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.

func (*HtmlToImageClient) GetConsumedCreditCount

func (client *HtmlToImageClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*HtmlToImageClient) GetDebugLogUrl

func (client *HtmlToImageClient) GetDebugLogUrl() string

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

func (*HtmlToImageClient) GetJobId

func (client *HtmlToImageClient) GetJobId() string

Get the job id.

func (*HtmlToImageClient) GetOutputSize

func (client *HtmlToImageClient) GetOutputSize() int

Get the size of the output in bytes.

func (*HtmlToImageClient) GetRemainingCreditCount

func (client *HtmlToImageClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*HtmlToImageClient) GetVersion

func (client *HtmlToImageClient) GetVersion() string

Get the version details.

func (*HtmlToImageClient) SetAutoDetectElementToConvert

func (client *HtmlToImageClient) SetAutoDetectElementToConvert(value bool) *HtmlToImageClient

The main HTML element for conversion is detected automatically.

value - Set to true to detect the main element.

func (*HtmlToImageClient) SetBackgroundColor

func (client *HtmlToImageClient) SetBackgroundColor(color string) *HtmlToImageClient

The output image background color.

color - The value must be in RRGGBB or RRGGBBAA hexadecimal format.

func (*HtmlToImageClient) SetBlockAds

func (client *HtmlToImageClient) SetBlockAds(value bool) *HtmlToImageClient

Try to block ads. Enabling this option can produce smaller output and speed up the conversion.

value - Set to true to block ads in web pages.

func (*HtmlToImageClient) SetClientCertificate

func (client *HtmlToImageClient) SetClientCertificate(certificate string) *HtmlToImageClient

A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.

certificate - The file must be in PKCS12 format. The file must exist and not be empty.

func (*HtmlToImageClient) SetClientCertificatePassword

func (client *HtmlToImageClient) SetClientCertificatePassword(password string) *HtmlToImageClient

A password for PKCS12 file with a client certificate if it is needed.

password -

func (*HtmlToImageClient) SetClientUserAgent

func (client *HtmlToImageClient) SetClientUserAgent(agent string) *HtmlToImageClient

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

agent - The user agent string.

func (*HtmlToImageClient) SetConverterUserAgent

func (client *HtmlToImageClient) SetConverterUserAgent(agent string) *HtmlToImageClient

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

agent - The user agent.

func (*HtmlToImageClient) SetConverterVersion

func (client *HtmlToImageClient) SetConverterVersion(version string) *HtmlToImageClient

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

version - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.

func (*HtmlToImageClient) SetCookies

func (client *HtmlToImageClient) SetCookies(cookies string) *HtmlToImageClient

Set cookies that are sent in Pdfcrowd HTTP requests.

cookies - The cookie string.

func (*HtmlToImageClient) SetCustomCss

func (client *HtmlToImageClient) SetCustomCss(css string) *HtmlToImageClient

Apply custom CSS to the input HTML document. It allows you to modify the visual appearance and layout of your HTML content dynamically. Tip: Using !important in custom CSS provides a way to prioritize and override conflicting styles.

css - A string containing valid CSS. The string must not be empty.

func (*HtmlToImageClient) SetCustomHttpHeader

func (client *HtmlToImageClient) SetCustomHttpHeader(header string) *HtmlToImageClient

Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.

header - A string containing the header name and value separated by a colon.

func (*HtmlToImageClient) SetCustomJavascript

func (client *HtmlToImageClient) SetCustomJavascript(javascript string) *HtmlToImageClient

Run a custom JavaScript after the document is loaded and ready to print. 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.

javascript - A string containing a JavaScript code. The string must not be empty.

func (*HtmlToImageClient) SetDataAutoEscape

func (client *HtmlToImageClient) SetDataAutoEscape(value bool) *HtmlToImageClient

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

value - Set to true to turn auto escaping on.

func (*HtmlToImageClient) SetDataEncoding

func (client *HtmlToImageClient) SetDataEncoding(encoding string) *HtmlToImageClient

Set the encoding of the data file set by setDataFile.

encoding - The data file encoding.

func (*HtmlToImageClient) SetDataFile

func (client *HtmlToImageClient) SetDataFile(dataFile string) *HtmlToImageClient

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

dataFile - The file path to a local file containing the input data.

func (*HtmlToImageClient) SetDataFormat

func (client *HtmlToImageClient) SetDataFormat(dataFormat string) *HtmlToImageClient

Specify the input data format.

dataFormat - The data format. Allowed values are auto, json, xml, yaml, csv.

func (*HtmlToImageClient) SetDataIgnoreUndefined

func (client *HtmlToImageClient) SetDataIgnoreUndefined(value bool) *HtmlToImageClient

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.

value - Set to true to ignore undefined variables.

func (*HtmlToImageClient) SetDataOptions

func (client *HtmlToImageClient) SetDataOptions(options string) *HtmlToImageClient

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.

options - Comma separated list of options.

func (*HtmlToImageClient) SetDataString

func (client *HtmlToImageClient) SetDataString(dataString string) *HtmlToImageClient

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

dataString - The input data string.

func (*HtmlToImageClient) SetDataTrimBlocks

func (client *HtmlToImageClient) SetDataTrimBlocks(value bool) *HtmlToImageClient

Auto trim whitespace around each template command block.

value - Set to true to turn auto trimming on.

func (*HtmlToImageClient) SetDebugLog

func (client *HtmlToImageClient) SetDebugLog(value bool) *HtmlToImageClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*HtmlToImageClient) SetDefaultEncoding

func (client *HtmlToImageClient) SetDefaultEncoding(encoding string) *HtmlToImageClient

Set the default HTML content text encoding.

encoding - The text encoding of the HTML content.

func (*HtmlToImageClient) SetDisableImageLoading

func (client *HtmlToImageClient) SetDisableImageLoading(value bool) *HtmlToImageClient

Do not load images.

value - Set to true to disable loading of images.

func (*HtmlToImageClient) SetDisableJavascript

func (client *HtmlToImageClient) SetDisableJavascript(value bool) *HtmlToImageClient

Do not execute JavaScript.

value - Set to true to disable JavaScript in web pages.

func (*HtmlToImageClient) SetDisableRemoteFonts

func (client *HtmlToImageClient) SetDisableRemoteFonts(value bool) *HtmlToImageClient

Disable loading fonts from remote sources.

value - Set to true disable loading remote fonts.

func (*HtmlToImageClient) SetElementToConvert

func (client *HtmlToImageClient) SetElementToConvert(selectors string) *HtmlToImageClient

Convert only the specified element from the main document and its children. 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.

selectors - One or more CSS selectors separated by commas. The string must not be empty.

func (*HtmlToImageClient) SetElementToConvertMode

func (client *HtmlToImageClient) SetElementToConvertMode(mode string) *HtmlToImageClient

Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.

mode - Allowed values are cut-out, remove-siblings, hide-siblings.

func (*HtmlToImageClient) SetFailOnAnyUrlError

func (client *HtmlToImageClient) SetFailOnAnyUrlError(failOnError bool) *HtmlToImageClient

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. See details in a debug log.

failOnError - Set to true to abort the conversion.

func (*HtmlToImageClient) SetFailOnMainUrlError

func (client *HtmlToImageClient) SetFailOnMainUrlError(failOnError bool) *HtmlToImageClient

Abort the conversion if the main URL HTTP status code is greater than or equal to 400.

failOnError - Set to true to abort the conversion.

func (*HtmlToImageClient) SetHttpAuth

func (client *HtmlToImageClient) SetHttpAuth(userName string, password string) *HtmlToImageClient

Set credentials to access HTTP base authentication protected websites.

userName - Set the HTTP authentication user name. password - Set the HTTP authentication password.

func (*HtmlToImageClient) SetHttpAuthPassword

func (client *HtmlToImageClient) SetHttpAuthPassword(password string) *HtmlToImageClient

func (*HtmlToImageClient) SetHttpAuthUserName

func (client *HtmlToImageClient) SetHttpAuthUserName(userName string) *HtmlToImageClient

func (*HtmlToImageClient) SetHttpProxy

func (client *HtmlToImageClient) SetHttpProxy(proxy string) *HtmlToImageClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*HtmlToImageClient) SetHttpsProxy

func (client *HtmlToImageClient) SetHttpsProxy(proxy string) *HtmlToImageClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*HtmlToImageClient) SetJavascriptDelay

func (client *HtmlToImageClient) SetJavascriptDelay(delay int) *HtmlToImageClient

Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.

delay - The number of milliseconds to wait. Must be a positive integer number or 0.

func (*HtmlToImageClient) SetLoadIframes

func (client *HtmlToImageClient) SetLoadIframes(iframes string) *HtmlToImageClient

Specifies how iframes are handled.

iframes - Allowed values are all, same-origin, none.

func (*HtmlToImageClient) SetLocale

func (client *HtmlToImageClient) SetLocale(locale string) *HtmlToImageClient

Set the locale for the conversion. This may affect the output format of dates, times and numbers.

locale - The locale code according to ISO 639.

func (*HtmlToImageClient) SetMaxLoadingTime

func (client *HtmlToImageClient) SetMaxLoadingTime(maxTime int) *HtmlToImageClient

Set the maximum time to load 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.

maxTime - The number of seconds to wait. The value must be in the range 10-30.

func (*HtmlToImageClient) SetNoBackground

func (client *HtmlToImageClient) SetNoBackground(value bool) *HtmlToImageClient

Do not print the background graphics.

value - Set to true to disable the background graphics.

func (*HtmlToImageClient) SetNoXpdfcrowdHeader

func (client *HtmlToImageClient) SetNoXpdfcrowdHeader(value bool) *HtmlToImageClient

Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.

value - Set to true to disable sending X-Pdfcrowd HTTP header.

func (*HtmlToImageClient) SetOnLoadJavascript

func (client *HtmlToImageClient) SetOnLoadJavascript(javascript string) *HtmlToImageClient

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.

javascript - A string containing a JavaScript code. The string must not be empty.

func (*HtmlToImageClient) SetOutputFormat

func (client *HtmlToImageClient) SetOutputFormat(outputFormat string) *HtmlToImageClient

The format of the output file.

outputFormat - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.

func (*HtmlToImageClient) SetProxy

func (client *HtmlToImageClient) SetProxy(host string, port int, userName string, password string) *HtmlToImageClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*HtmlToImageClient) SetReadabilityEnhancements

func (client *HtmlToImageClient) SetReadabilityEnhancements(enhancements string) *HtmlToImageClient

The input HTML is automatically enhanced to improve the readability.

enhancements - Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.

func (*HtmlToImageClient) SetRetryCount

func (client *HtmlToImageClient) SetRetryCount(count int) *HtmlToImageClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*HtmlToImageClient) SetScaleFactor

func (client *HtmlToImageClient) SetScaleFactor(factor int) *HtmlToImageClient

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

factor - The percentage value. Must be a positive integer number.

func (*HtmlToImageClient) SetScreenshotHeight

func (client *HtmlToImageClient) SetScreenshotHeight(height int) *HtmlToImageClient

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

height - Must be a positive integer number.

func (*HtmlToImageClient) SetScreenshotWidth

func (client *HtmlToImageClient) SetScreenshotWidth(width int) *HtmlToImageClient

Set the output image width in pixels.

width - The value must be in the range 96-65000.

func (*HtmlToImageClient) SetSubprocessReferrer

func (client *HtmlToImageClient) SetSubprocessReferrer(referrer string) *HtmlToImageClient

func (*HtmlToImageClient) SetTag

func (client *HtmlToImageClient) SetTag(tag string) *HtmlToImageClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*HtmlToImageClient) SetUseHttp

func (client *HtmlToImageClient) SetUseHttp(value bool) *HtmlToImageClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*HtmlToImageClient) SetUseMobileUserAgent

func (client *HtmlToImageClient) SetUseMobileUserAgent(value bool) *HtmlToImageClient

Use a mobile user agent.

value - Set to true to use a mobile user agent.

func (*HtmlToImageClient) SetUsePrintMedia

func (client *HtmlToImageClient) SetUsePrintMedia(value bool) *HtmlToImageClient

Use the print version of the page if available (@media print).

value - Set to true to use the print version of the page.

func (*HtmlToImageClient) SetUserAgent

func (client *HtmlToImageClient) SetUserAgent(agent string) *HtmlToImageClient

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

agent - The user agent string.

func (*HtmlToImageClient) SetVerifySslCertificates

func (client *HtmlToImageClient) SetVerifySslCertificates(value bool) *HtmlToImageClient

Do not allow insecure HTTPS connections.

value - Set to true to enable SSL certificate verification.

func (*HtmlToImageClient) SetWaitForElement

func (client *HtmlToImageClient) SetWaitForElement(selectors string) *HtmlToImageClient

Wait for the specified element in a source document. 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 API license defines the maximum wait time by "Max Delay" parameter.

selectors - One or more CSS selectors separated by commas. The string must not be empty.

func (*HtmlToImageClient) SetZipMainFilename

func (client *HtmlToImageClient) SetZipMainFilename(filename string) *HtmlToImageClient

Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.

filename - The file name.

type HtmlToPdfClient

type HtmlToPdfClient struct {
	// contains filtered or unexported fields
}

Conversion from HTML to PDF.

func NewHtmlToPdfClient

func NewHtmlToPdfClient(userName string, apiKey string) HtmlToPdfClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*HtmlToPdfClient) ConvertFile

func (client *HtmlToPdfClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

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. The file must exist and not be empty. The file name must have a valid extension.

func (*HtmlToPdfClient) ConvertFileToFile

func (client *HtmlToPdfClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

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. The file must exist and not be empty. The file name must have a valid extension. filePath - The output file path. The string must not be empty.

func (*HtmlToPdfClient) ConvertFileToStream

func (client *HtmlToPdfClient) ConvertFileToStream(file string, outStream io.Writer) error

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

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. The file must exist and not be empty. The file name must have a valid extension. outStream - The output stream that will contain the conversion output.

func (*HtmlToPdfClient) ConvertStream

func (client *HtmlToPdfClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - 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).

func (*HtmlToPdfClient) ConvertStreamToFile

func (client *HtmlToPdfClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - 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. The string must not be empty.

func (*HtmlToPdfClient) ConvertStreamToStream

func (client *HtmlToPdfClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - 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 - The output stream that will contain the conversion output.

func (*HtmlToPdfClient) ConvertString

func (client *HtmlToPdfClient) ConvertString(text string) ([]byte, error)

Convert a string.

text - The string content to convert. The string must not be empty.

func (*HtmlToPdfClient) ConvertStringToFile

func (client *HtmlToPdfClient) ConvertStringToFile(text string, filePath string) error

Convert a string and write the output to a file.

text - The string content to convert. The string must not be empty. filePath - The output file path. The string must not be empty.

func (*HtmlToPdfClient) ConvertStringToStream

func (client *HtmlToPdfClient) ConvertStringToStream(text string, outStream io.Writer) error

Convert a string and write the output to an output stream.

text - The string content to convert. The string must not be empty. outStream - The output stream that will contain the conversion output.

func (*HtmlToPdfClient) ConvertUrl

func (client *HtmlToPdfClient) ConvertUrl(url string) ([]byte, error)

Convert a web page.

url - The address of the web page to convert. The supported protocols are http:// and https://.

func (*HtmlToPdfClient) ConvertUrlToFile

func (client *HtmlToPdfClient) ConvertUrlToFile(url string, filePath string) error

Convert a web page and write the result to a local file.

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.

func (*HtmlToPdfClient) ConvertUrlToStream

func (client *HtmlToPdfClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert a web page and write the result to an output stream.

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.

func (*HtmlToPdfClient) GetConsumedCreditCount

func (client *HtmlToPdfClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*HtmlToPdfClient) GetDebugLogUrl

func (client *HtmlToPdfClient) GetDebugLogUrl() string

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

func (*HtmlToPdfClient) GetJobId

func (client *HtmlToPdfClient) GetJobId() string

Get the job id.

func (*HtmlToPdfClient) GetOutputSize

func (client *HtmlToPdfClient) GetOutputSize() int

Get the size of the output in bytes.

func (*HtmlToPdfClient) GetPageCount

func (client *HtmlToPdfClient) GetPageCount() int

Get the number of pages in the output document.

func (*HtmlToPdfClient) GetRemainingCreditCount

func (client *HtmlToPdfClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*HtmlToPdfClient) GetTotalPageCount

func (client *HtmlToPdfClient) GetTotalPageCount() int

Get the total number of pages in the original output document, including the pages excluded by setPrintPageRange().

func (*HtmlToPdfClient) GetVersion

func (client *HtmlToPdfClient) GetVersion() string

Get the version details.

func (*HtmlToPdfClient) SetAuthor

func (client *HtmlToPdfClient) SetAuthor(author string) *HtmlToPdfClient

Set the author of the PDF.

author - The author.

func (*HtmlToPdfClient) SetAutoDetectElementToConvert

func (client *HtmlToPdfClient) SetAutoDetectElementToConvert(value bool) *HtmlToPdfClient

The main HTML element for conversion is detected automatically.

value - Set to true to detect the main element.

func (*HtmlToPdfClient) SetBlockAds

func (client *HtmlToPdfClient) SetBlockAds(value bool) *HtmlToPdfClient

Try to block ads. Enabling this option can produce smaller output and speed up the conversion.

value - Set to true to block ads in web pages.

func (*HtmlToPdfClient) SetCenterWindow

func (client *HtmlToPdfClient) SetCenterWindow(value bool) *HtmlToPdfClient

Specify whether to position the document's window in the center of the screen.

value - Set to true to center the window.

func (*HtmlToPdfClient) SetClientCertificate

func (client *HtmlToPdfClient) SetClientCertificate(certificate string) *HtmlToPdfClient

A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.

certificate - The file must be in PKCS12 format. The file must exist and not be empty.

func (*HtmlToPdfClient) SetClientCertificatePassword

func (client *HtmlToPdfClient) SetClientCertificatePassword(password string) *HtmlToPdfClient

A password for PKCS12 file with a client certificate if it is needed.

password -

func (*HtmlToPdfClient) SetClientUserAgent

func (client *HtmlToPdfClient) SetClientUserAgent(agent string) *HtmlToPdfClient

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

agent - The user agent string.

func (*HtmlToPdfClient) SetContentArea

func (client *HtmlToPdfClient) SetContentArea(x string, y string, width string, height string) *HtmlToPdfClient

Set the content area position and size. The content area enables to specify a web page area to be converted.

x - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value. y - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value. width - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". height - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetContentAreaHeight

func (client *HtmlToPdfClient) SetContentAreaHeight(height string) *HtmlToPdfClient

Set the height of the content area. It should be at least 1 inch.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetContentAreaWidth

func (client *HtmlToPdfClient) SetContentAreaWidth(width string) *HtmlToPdfClient

Set the width of the content area. It should be at least 1 inch.

width - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetContentAreaX

func (client *HtmlToPdfClient) SetContentAreaX(x string) *HtmlToPdfClient

Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.

x - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value.

func (*HtmlToPdfClient) SetContentAreaY

func (client *HtmlToPdfClient) SetContentAreaY(y string) *HtmlToPdfClient

Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.

y - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value.

func (*HtmlToPdfClient) SetContentFitMode

func (client *HtmlToPdfClient) SetContentFitMode(mode string) *HtmlToPdfClient

Specifies the mode for fitting the HTML content to the print area by upscaling or downscaling it.

mode - The fitting mode. Allowed values are auto, smart-scaling, no-scaling, viewport-width, content-width, single-page, single-page-ratio.

func (*HtmlToPdfClient) SetContentViewportHeight

func (client *HtmlToPdfClient) SetContentViewportHeight(height string) *HtmlToPdfClient

Set the viewport height for formatting the HTML content when generating a PDF. By specifying a viewport height, you can enforce loading of lazy-loaded images and also affect vertical positioning of absolutely positioned elements within the content.

height - The viewport height. The value must be "auto", "large", or a number.

func (*HtmlToPdfClient) SetContentViewportWidth

func (client *HtmlToPdfClient) SetContentViewportWidth(width string) *HtmlToPdfClient

Set the viewport width for formatting the HTML content when generating a PDF. By specifying a viewport width, you can control how the content is rendered, ensuring it mimics the appearance on various devices or matches specific design requirements.

width - The width of the viewport. The value must be "balanced", "small", "medium", "large", "extra-large", or a number in the range 96-65000px.

func (*HtmlToPdfClient) SetContentsMatrix

func (client *HtmlToPdfClient) SetContentsMatrix(matrix string) *HtmlToPdfClient

A 2D transformation matrix applied to the main contents on each page. The origin [0,0] is located at the top-left corner of the contents. The resolution is 72 dpi.

matrix - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"

func (*HtmlToPdfClient) SetConversionConfig

func (client *HtmlToPdfClient) SetConversionConfig(jsonString string) *HtmlToPdfClient

Allows to configure conversion via JSON. The configuration defines various page settings for individual PDF pages or ranges of pages. It provides flexibility in designing each page of the PDF, giving control over each page's size, header, footer etc. If a page or parameter is not explicitly specified, the system will use the default settings for that page or attribute. If a JSON configuration is provided, the settings in the JSON will take precedence over the global options. The structure of the JSON must be: pageSetup: An array of objects where each object defines the configuration for a specific page or range of pages. The following properties can be set for each page object: pages: A comma-separated list of page numbers or ranges. Special strings may be used, such as `odd`, `even` and `last`. For example: 1-: from page 1 to the end of the document 2: only the 2nd page 2,4,6: pages 2, 4, and 6 2-5: pages 2 through 5 odd,2: the 2nd page and all odd pages pageSize: The page size (optional). Possible values: A0, A1, A2, A3, A4, A5, A6, Letter. pageWidth: The width of the page (optional). pageHeight: The height of the page (optional). marginLeft: Left margin (optional). marginRight: Right margin (optional). marginTop: Top margin (optional). marginBottom: Bottom margin (optional). displayHeader: Header appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) displayFooter: Footer appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) headerHeight: Height of the header (optional). footerHeight: Height of the footer (optional). orientation: Page orientation, such as "portrait" or "landscape" (optional). backgroundColor: Page background color in RRGGBB or RRGGBBAA hexadecimal format (optional). Dimensions may be empty, 0 or specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

jsonString - The JSON string.

func (*HtmlToPdfClient) SetConversionConfigFile

func (client *HtmlToPdfClient) SetConversionConfigFile(filepath string) *HtmlToPdfClient

Allows to configure the conversion process via JSON file. See details of the JSON string.

filepath - The file path to a local file. The file must exist and not be empty.

func (*HtmlToPdfClient) SetConvertImagesToJpeg

func (client *HtmlToPdfClient) SetConvertImagesToJpeg(images string) *HtmlToPdfClient

Specify which image types will be converted to JPEG. Converting lossless compression image formats (PNG, GIF, ...) to JPEG may result in a smaller PDF file.

images - The image category. Allowed values are none, opaque, all.

func (*HtmlToPdfClient) SetConverterUserAgent

func (client *HtmlToPdfClient) SetConverterUserAgent(agent string) *HtmlToPdfClient

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

agent - The user agent.

func (*HtmlToPdfClient) SetConverterVersion

func (client *HtmlToPdfClient) SetConverterVersion(version string) *HtmlToPdfClient

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

version - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.

func (*HtmlToPdfClient) SetCookies

func (client *HtmlToPdfClient) SetCookies(cookies string) *HtmlToPdfClient

Set cookies that are sent in Pdfcrowd HTTP requests.

cookies - The cookie string.

func (*HtmlToPdfClient) SetCssPageRuleMode

func (client *HtmlToPdfClient) SetCssPageRuleMode(mode string) *HtmlToPdfClient

Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.

mode - The page rule mode. Allowed values are default, mode1, mode2.

func (*HtmlToPdfClient) SetCustomCss

func (client *HtmlToPdfClient) SetCustomCss(css string) *HtmlToPdfClient

Apply custom CSS to the input HTML document. It allows you to modify the visual appearance and layout of your HTML content dynamically. Tip: Using !important in custom CSS provides a way to prioritize and override conflicting styles.

css - A string containing valid CSS. The string must not be empty.

func (*HtmlToPdfClient) SetCustomHttpHeader

func (client *HtmlToPdfClient) SetCustomHttpHeader(header string) *HtmlToPdfClient

Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.

header - A string containing the header name and value separated by a colon.

func (*HtmlToPdfClient) SetCustomJavascript

func (client *HtmlToPdfClient) SetCustomJavascript(javascript string) *HtmlToPdfClient

Run a custom JavaScript after the document is loaded and ready to print. 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.

javascript - A string containing a JavaScript code. The string must not be empty.

func (*HtmlToPdfClient) SetDataAutoEscape

func (client *HtmlToPdfClient) SetDataAutoEscape(value bool) *HtmlToPdfClient

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

value - Set to true to turn auto escaping on.

func (*HtmlToPdfClient) SetDataEncoding

func (client *HtmlToPdfClient) SetDataEncoding(encoding string) *HtmlToPdfClient

Set the encoding of the data file set by setDataFile.

encoding - The data file encoding.

func (*HtmlToPdfClient) SetDataFile

func (client *HtmlToPdfClient) SetDataFile(dataFile string) *HtmlToPdfClient

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

dataFile - The file path to a local file containing the input data.

func (*HtmlToPdfClient) SetDataFormat

func (client *HtmlToPdfClient) SetDataFormat(dataFormat string) *HtmlToPdfClient

Specify the input data format.

dataFormat - The data format. Allowed values are auto, json, xml, yaml, csv.

func (*HtmlToPdfClient) SetDataIgnoreUndefined

func (client *HtmlToPdfClient) SetDataIgnoreUndefined(value bool) *HtmlToPdfClient

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.

value - Set to true to ignore undefined variables.

func (*HtmlToPdfClient) SetDataOptions

func (client *HtmlToPdfClient) SetDataOptions(options string) *HtmlToPdfClient

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.

options - Comma separated list of options.

func (*HtmlToPdfClient) SetDataString

func (client *HtmlToPdfClient) SetDataString(dataString string) *HtmlToPdfClient

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

dataString - The input data string.

func (*HtmlToPdfClient) SetDataTrimBlocks

func (client *HtmlToPdfClient) SetDataTrimBlocks(value bool) *HtmlToPdfClient

Auto trim whitespace around each template command block.

value - Set to true to turn auto trimming on.

func (*HtmlToPdfClient) SetDebugLog

func (client *HtmlToPdfClient) SetDebugLog(value bool) *HtmlToPdfClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*HtmlToPdfClient) SetDefaultEncoding

func (client *HtmlToPdfClient) SetDefaultEncoding(encoding string) *HtmlToPdfClient

Set the default HTML content text encoding.

encoding - The text encoding of the HTML content.

func (*HtmlToPdfClient) SetDisableImageLoading

func (client *HtmlToPdfClient) SetDisableImageLoading(value bool) *HtmlToPdfClient

Do not load images.

value - Set to true to disable loading of images.

func (*HtmlToPdfClient) SetDisableJavascript

func (client *HtmlToPdfClient) SetDisableJavascript(value bool) *HtmlToPdfClient

Do not execute JavaScript.

value - Set to true to disable JavaScript in web pages.

func (*HtmlToPdfClient) SetDisablePageHeightOptimization

func (client *HtmlToPdfClient) SetDisablePageHeightOptimization(value bool) *HtmlToPdfClient

Disable automatic height adjustment that compensates for pixel to point rounding errors.

value - Set to true to disable automatic height scale.

func (*HtmlToPdfClient) SetDisableRemoteFonts

func (client *HtmlToPdfClient) SetDisableRemoteFonts(value bool) *HtmlToPdfClient

Disable loading fonts from remote sources.

value - Set to true disable loading remote fonts.

func (*HtmlToPdfClient) SetDisplayTitle

func (client *HtmlToPdfClient) SetDisplayTitle(value bool) *HtmlToPdfClient

Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.

value - Set to true to display the title.

func (*HtmlToPdfClient) SetElementToConvert

func (client *HtmlToPdfClient) SetElementToConvert(selectors string) *HtmlToPdfClient

Convert only the specified element from the main document and its children. 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.

selectors - One or more CSS selectors separated by commas. The string must not be empty.

func (*HtmlToPdfClient) SetElementToConvertMode

func (client *HtmlToPdfClient) SetElementToConvertMode(mode string) *HtmlToPdfClient

Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.

mode - Allowed values are cut-out, remove-siblings, hide-siblings.

func (*HtmlToPdfClient) SetEnablePdfForms

func (client *HtmlToPdfClient) SetEnablePdfForms(value bool) *HtmlToPdfClient

Convert HTML forms to fillable PDF forms. Details can be found in the blog post.

value - Set to true to make fillable PDF forms.

func (*HtmlToPdfClient) SetEncrypt

func (client *HtmlToPdfClient) SetEncrypt(value bool) *HtmlToPdfClient

Encrypt the PDF. This prevents search engines from indexing the contents.

value - Set to true to enable PDF encryption.

func (*HtmlToPdfClient) SetExcludeFooterOnPages

func (client *HtmlToPdfClient) SetExcludeFooterOnPages(pages string) *HtmlToPdfClient

The page footer content is not printed on the specified pages. To remove the entire footer area, use the conversion config.

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 separated list of page numbers.

func (*HtmlToPdfClient) SetExcludeHeaderOnPages

func (client *HtmlToPdfClient) SetExcludeHeaderOnPages(pages string) *HtmlToPdfClient

The page header content is not printed on the specified pages. To remove the entire header area, use the conversion config.

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 separated list of page numbers.

func (*HtmlToPdfClient) SetExtractMetaTags

func (client *HtmlToPdfClient) SetExtractMetaTags(value bool) *HtmlToPdfClient

Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.

value - Set to true to extract meta tags.

func (*HtmlToPdfClient) SetFailOnAnyUrlError

func (client *HtmlToPdfClient) SetFailOnAnyUrlError(failOnError bool) *HtmlToPdfClient

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. See details in a debug log.

failOnError - Set to true to abort the conversion.

func (*HtmlToPdfClient) SetFailOnMainUrlError

func (client *HtmlToPdfClient) SetFailOnMainUrlError(failOnError bool) *HtmlToPdfClient

Abort the conversion if the main URL HTTP status code is greater than or equal to 400.

failOnError - Set to true to abort the conversion.

func (*HtmlToPdfClient) SetFitWindow

func (client *HtmlToPdfClient) SetFitWindow(value bool) *HtmlToPdfClient

Specify whether to resize the document's window to fit the size of the first displayed page.

value - Set to true to resize the window.

func (*HtmlToPdfClient) SetFooterHeight

func (client *HtmlToPdfClient) SetFooterHeight(height string) *HtmlToPdfClient

Set the footer height.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetFooterHtml

func (client *HtmlToPdfClient) SetFooterHtml(html string) *HtmlToPdfClient

Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>

html - The string must not be empty.

func (*HtmlToPdfClient) SetFooterMatrix

func (client *HtmlToPdfClient) SetFooterMatrix(matrix string) *HtmlToPdfClient

A 2D transformation matrix applied to the page footer contents. The origin [0,0] is located at the top-left corner of the footer. The resolution is 72 dpi.

matrix - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"

func (*HtmlToPdfClient) SetFooterUrl

func (client *HtmlToPdfClient) SetFooterUrl(url string) *HtmlToPdfClient

Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>

url - The supported protocols are http:// and https://.

func (*HtmlToPdfClient) SetHeaderFooterCssAnnotation

func (client *HtmlToPdfClient) SetHeaderFooterCssAnnotation(value bool) *HtmlToPdfClient

Add special CSS classes to the header/footer's body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-count-X - where X is the total page count pdfcrowd-page-first - the first page pdfcrowd-page-last - the last page pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page

value - Set to true to add the special CSS classes.

func (*HtmlToPdfClient) SetHeaderFooterScaleFactor

func (client *HtmlToPdfClient) SetHeaderFooterScaleFactor(factor int) *HtmlToPdfClient

Set the scaling factor (zoom) for the header and footer.

factor - The percentage value. The value must be in the range 10-500.

func (*HtmlToPdfClient) SetHeaderHeight

func (client *HtmlToPdfClient) SetHeaderHeight(height string) *HtmlToPdfClient

Set the header height.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetHeaderHtml

func (client *HtmlToPdfClient) SetHeaderHtml(html string) *HtmlToPdfClient

Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>

html - The string must not be empty.

func (*HtmlToPdfClient) SetHeaderMatrix

func (client *HtmlToPdfClient) SetHeaderMatrix(matrix string) *HtmlToPdfClient

A 2D transformation matrix applied to the page header contents. The origin [0,0] is located at the top-left corner of the header. The resolution is 72 dpi.

matrix - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"

func (*HtmlToPdfClient) SetHeaderUrl

func (client *HtmlToPdfClient) SetHeaderUrl(url string) *HtmlToPdfClient

Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>

url - The supported protocols are http:// and https://.

func (*HtmlToPdfClient) SetHideMenubar

func (client *HtmlToPdfClient) SetHideMenubar(value bool) *HtmlToPdfClient

Specify whether to hide the viewer application's menu bar when the document is active.

value - Set to true to hide the menu bar.

func (*HtmlToPdfClient) SetHideToolbar

func (client *HtmlToPdfClient) SetHideToolbar(value bool) *HtmlToPdfClient

Specify whether to hide the viewer application's tool bars when the document is active.

value - Set to true to hide tool bars.

func (*HtmlToPdfClient) SetHideWindowUi

func (client *HtmlToPdfClient) SetHideWindowUi(value bool) *HtmlToPdfClient

Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.

value - Set to true to hide ui elements.

func (*HtmlToPdfClient) SetHttpAuth

func (client *HtmlToPdfClient) SetHttpAuth(userName string, password string) *HtmlToPdfClient

Set credentials to access HTTP base authentication protected websites.

userName - Set the HTTP authentication user name. password - Set the HTTP authentication password.

func (*HtmlToPdfClient) SetHttpAuthPassword

func (client *HtmlToPdfClient) SetHttpAuthPassword(password string) *HtmlToPdfClient

func (*HtmlToPdfClient) SetHttpAuthUserName

func (client *HtmlToPdfClient) SetHttpAuthUserName(userName string) *HtmlToPdfClient

func (*HtmlToPdfClient) SetHttpProxy

func (client *HtmlToPdfClient) SetHttpProxy(proxy string) *HtmlToPdfClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*HtmlToPdfClient) SetHttpsProxy

func (client *HtmlToPdfClient) SetHttpsProxy(proxy string) *HtmlToPdfClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*HtmlToPdfClient) SetImageDpi

func (client *HtmlToPdfClient) SetImageDpi(dpi int) *HtmlToPdfClient

Set the DPI of images in PDF. A lower DPI may result in a smaller PDF file. If the specified DPI is higher than the actual image DPI, the original image DPI is retained (no upscaling is performed). Use 0 to leave the images unaltered.

dpi - The DPI value. Must be a positive integer number or 0.

func (*HtmlToPdfClient) SetInitialPage

func (client *HtmlToPdfClient) SetInitialPage(page int) *HtmlToPdfClient

Display the specified page when the document is opened.

page - Must be a positive integer number.

func (*HtmlToPdfClient) SetInitialZoom

func (client *HtmlToPdfClient) SetInitialZoom(zoom int) *HtmlToPdfClient

Specify the initial page zoom in percents when the document is opened.

zoom - Must be a positive integer number.

func (*HtmlToPdfClient) SetInitialZoomType

func (client *HtmlToPdfClient) SetInitialZoomType(zoomType string) *HtmlToPdfClient

Specify how the page should be displayed when opened.

zoomType - Allowed values are fit-width, fit-height, fit-page.

func (*HtmlToPdfClient) SetJavascriptDelay

func (client *HtmlToPdfClient) SetJavascriptDelay(delay int) *HtmlToPdfClient

Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.

delay - The number of milliseconds to wait. Must be a positive integer number or 0.

func (*HtmlToPdfClient) SetJpegQuality

func (client *HtmlToPdfClient) SetJpegQuality(quality int) *HtmlToPdfClient

Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.

quality - The percentage value. The value must be in the range 1-100.

func (*HtmlToPdfClient) SetKeywords

func (client *HtmlToPdfClient) SetKeywords(keywords string) *HtmlToPdfClient

Associate keywords with the document.

keywords - The string with the keywords.

func (*HtmlToPdfClient) SetLayoutDpi

func (client *HtmlToPdfClient) SetLayoutDpi(dpi int) *HtmlToPdfClient

Set the internal DPI resolution used for positioning of PDF contents. It can help in situations when there are small inaccuracies in the PDF. It is recommended to use values that are a multiple of 72, such as 288 or 360.

dpi - The DPI value. The value must be in the range of 72-600.

func (*HtmlToPdfClient) SetLinearize

func (client *HtmlToPdfClient) SetLinearize(value bool) *HtmlToPdfClient

Create linearized PDF. This is also known as Fast Web View.

value - Set to true to create linearized PDF.

func (*HtmlToPdfClient) SetLoadIframes

func (client *HtmlToPdfClient) SetLoadIframes(iframes string) *HtmlToPdfClient

Specifies how iframes are handled.

iframes - Allowed values are all, same-origin, none.

func (*HtmlToPdfClient) SetLocale

func (client *HtmlToPdfClient) SetLocale(locale string) *HtmlToPdfClient

Set the locale for the conversion. This may affect the output format of dates, times and numbers.

locale - The locale code according to ISO 639.

func (*HtmlToPdfClient) SetMainDocumentCssAnnotation

func (client *HtmlToPdfClient) SetMainDocumentCssAnnotation(value bool) *HtmlToPdfClient

Add special CSS classes to the main document's body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page Warning: If your custom styling affects the contents area size (e.g. by using different margins, padding, border width), the resulting PDF may contain duplicit contents or some contents may be missing.

value - Set to true to add the special CSS classes.

func (*HtmlToPdfClient) SetMarginBottom

func (client *HtmlToPdfClient) SetMarginBottom(bottom string) *HtmlToPdfClient

Set the output page bottom margin.

bottom - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetMarginLeft

func (client *HtmlToPdfClient) SetMarginLeft(left string) *HtmlToPdfClient

Set the output page left margin.

left - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetMarginRight

func (client *HtmlToPdfClient) SetMarginRight(right string) *HtmlToPdfClient

Set the output page right margin.

right - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetMarginTop

func (client *HtmlToPdfClient) SetMarginTop(top string) *HtmlToPdfClient

Set the output page top margin.

top - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetMaxLoadingTime

func (client *HtmlToPdfClient) SetMaxLoadingTime(maxTime int) *HtmlToPdfClient

Set the maximum time to load 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.

maxTime - The number of seconds to wait. The value must be in the range 10-30.

func (*HtmlToPdfClient) SetMultipageBackground

func (client *HtmlToPdfClient) SetMultipageBackground(background string) *HtmlToPdfClient

Apply each page of a background to the corresponding page of the output PDF. A background can be either a PDF or an image.

background - The file path to a local file. The file must exist and not be empty.

func (*HtmlToPdfClient) SetMultipageBackgroundUrl

func (client *HtmlToPdfClient) SetMultipageBackgroundUrl(url string) *HtmlToPdfClient

Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.

url - The supported protocols are http:// and https://.

func (*HtmlToPdfClient) SetMultipageWatermark

func (client *HtmlToPdfClient) SetMultipageWatermark(watermark string) *HtmlToPdfClient

Apply each page of a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.

watermark - The file path to a local file. The file must exist and not be empty.

func (*HtmlToPdfClient) SetMultipageWatermarkUrl

func (client *HtmlToPdfClient) SetMultipageWatermarkUrl(url string) *HtmlToPdfClient

Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.

url - The supported protocols are http:// and https://.

func (*HtmlToPdfClient) SetNoBackground

func (client *HtmlToPdfClient) SetNoBackground(value bool) *HtmlToPdfClient

Do not print the background graphics.

value - Set to true to disable the background graphics.

func (*HtmlToPdfClient) SetNoCopy

func (client *HtmlToPdfClient) SetNoCopy(value bool) *HtmlToPdfClient

Disallow text and graphics extraction from the output PDF.

value - Set to true to set the no-copy flag in the output PDF.

func (*HtmlToPdfClient) SetNoHeaderFooterHorizontalMargins

func (client *HtmlToPdfClient) SetNoHeaderFooterHorizontalMargins(value bool) *HtmlToPdfClient

Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.

value - Set to true to disable horizontal margins for header and footer.

func (*HtmlToPdfClient) SetNoMargins

func (client *HtmlToPdfClient) SetNoMargins(value bool) *HtmlToPdfClient

Disable page margins.

value - Set to true to disable margins.

func (*HtmlToPdfClient) SetNoModify

func (client *HtmlToPdfClient) SetNoModify(value bool) *HtmlToPdfClient

Disallow modification of the output PDF.

value - Set to true to set the read-only only flag in the output PDF.

func (*HtmlToPdfClient) SetNoPrint

func (client *HtmlToPdfClient) SetNoPrint(value bool) *HtmlToPdfClient

Disallow printing of the output PDF.

value - Set to true to set the no-print flag in the output PDF.

func (*HtmlToPdfClient) SetNoXpdfcrowdHeader

func (client *HtmlToPdfClient) SetNoXpdfcrowdHeader(value bool) *HtmlToPdfClient

Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.

value - Set to true to disable sending X-Pdfcrowd HTTP header.

func (*HtmlToPdfClient) SetOnLoadJavascript

func (client *HtmlToPdfClient) SetOnLoadJavascript(javascript string) *HtmlToPdfClient

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.

javascript - A string containing a JavaScript code. The string must not be empty.

func (*HtmlToPdfClient) SetOrientation

func (client *HtmlToPdfClient) SetOrientation(orientation string) *HtmlToPdfClient

Set the output page orientation.

orientation - Allowed values are landscape, portrait.

func (*HtmlToPdfClient) SetOwnerPassword

func (client *HtmlToPdfClient) SetOwnerPassword(password string) *HtmlToPdfClient

Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.

password - The owner password.

func (*HtmlToPdfClient) SetPageBackground

func (client *HtmlToPdfClient) SetPageBackground(background string) *HtmlToPdfClient

Apply a background to each page of the output PDF file. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.

background - The file path to a local file. The file must exist and not be empty.

func (*HtmlToPdfClient) SetPageBackgroundColor

func (client *HtmlToPdfClient) SetPageBackgroundColor(color string) *HtmlToPdfClient

The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.

color - The value must be in RRGGBB or RRGGBBAA hexadecimal format.

func (*HtmlToPdfClient) SetPageBackgroundUrl

func (client *HtmlToPdfClient) SetPageBackgroundUrl(url string) *HtmlToPdfClient

Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.

url - The supported protocols are http:// and https://.

func (*HtmlToPdfClient) SetPageDimensions

func (client *HtmlToPdfClient) SetPageDimensions(width string, height string) *HtmlToPdfClient

Set the output page dimensions.

width - Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". height - Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF. The value must be -1 or specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetPageHeight

func (client *HtmlToPdfClient) SetPageHeight(height string) *HtmlToPdfClient

Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.

height - The value must be -1 or specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetPageLayout

func (client *HtmlToPdfClient) SetPageLayout(layout string) *HtmlToPdfClient

Specify the page layout to be used when the document is opened.

layout - Allowed values are single-page, one-column, two-column-left, two-column-right.

func (*HtmlToPdfClient) SetPageMargins

func (client *HtmlToPdfClient) SetPageMargins(top string, right string, bottom string, left string) *HtmlToPdfClient

Set the output page margins.

top - Set the output page top margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". right - Set the output page right margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". bottom - Set the output page bottom margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". left - Set the output page left margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetPageMode

func (client *HtmlToPdfClient) SetPageMode(mode string) *HtmlToPdfClient

Specify how the document should be displayed when opened.

mode - Allowed values are full-screen, thumbnails, outlines.

func (*HtmlToPdfClient) SetPageNumberingOffset

func (client *HtmlToPdfClient) SetPageNumberingOffset(offset int) *HtmlToPdfClient

Set an offset between physical and logical page numbers.

offset - Integer specifying page offset.

func (*HtmlToPdfClient) SetPageSize

func (client *HtmlToPdfClient) SetPageSize(size string) *HtmlToPdfClient

Set the output page size.

size - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.

func (*HtmlToPdfClient) SetPageWatermark

func (client *HtmlToPdfClient) SetPageWatermark(watermark string) *HtmlToPdfClient

Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.

watermark - The file path to a local file. The file must exist and not be empty.

func (*HtmlToPdfClient) SetPageWatermarkUrl

func (client *HtmlToPdfClient) SetPageWatermarkUrl(url string) *HtmlToPdfClient

Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.

url - The supported protocols are http:// and https://.

func (*HtmlToPdfClient) SetPageWidth

func (client *HtmlToPdfClient) SetPageWidth(width string) *HtmlToPdfClient

Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.

width - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*HtmlToPdfClient) SetPrintPageRange

func (client *HtmlToPdfClient) SetPrintPageRange(pages string) *HtmlToPdfClient

Set the page range to print.

pages - A comma separated list of page numbers or ranges. Special strings may be used, such as `odd`, `even` and `last`.

func (*HtmlToPdfClient) SetProxy

func (client *HtmlToPdfClient) SetProxy(host string, port int, userName string, password string) *HtmlToPdfClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*HtmlToPdfClient) SetReadabilityEnhancements

func (client *HtmlToPdfClient) SetReadabilityEnhancements(enhancements string) *HtmlToPdfClient

The input HTML is automatically enhanced to improve the readability.

enhancements - Allowed values are none, readability-v1, readability-v2, readability-v3, readability-v4.

func (*HtmlToPdfClient) SetRemoveBlankPages

func (client *HtmlToPdfClient) SetRemoveBlankPages(pages string) *HtmlToPdfClient

Specifies which blank pages to exclude from the output document.

pages - The empty page behavior. Allowed values are trailing, all, none.

func (*HtmlToPdfClient) SetRenderingMode

func (client *HtmlToPdfClient) SetRenderingMode(mode string) *HtmlToPdfClient

Set the rendering mode of the page, allowing control over how content is displayed.

mode - The rendering mode. Allowed values are default, viewport.

func (*HtmlToPdfClient) SetRetryCount

func (client *HtmlToPdfClient) SetRetryCount(count int) *HtmlToPdfClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*HtmlToPdfClient) SetRightToLeft

func (client *HtmlToPdfClient) SetRightToLeft(value bool) *HtmlToPdfClient

Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up

value - Set to true to set right-to-left reading order.

func (*HtmlToPdfClient) SetScaleFactor

func (client *HtmlToPdfClient) SetScaleFactor(factor int) *HtmlToPdfClient

Set the scaling factor (zoom) for the main page area.

factor - The percentage value. The value must be in the range 10-500.

func (*HtmlToPdfClient) SetSmartScalingMode

func (client *HtmlToPdfClient) SetSmartScalingMode(mode string) *HtmlToPdfClient

Specifies the scaling mode used for fitting the HTML contents to the print area.

mode - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, single-page-fit-ex, mode1.

func (*HtmlToPdfClient) SetSubject

func (client *HtmlToPdfClient) SetSubject(subject string) *HtmlToPdfClient

Set the subject of the PDF.

subject - The subject.

func (*HtmlToPdfClient) SetSubprocessReferrer

func (client *HtmlToPdfClient) SetSubprocessReferrer(referrer string) *HtmlToPdfClient

func (*HtmlToPdfClient) SetTag

func (client *HtmlToPdfClient) SetTag(tag string) *HtmlToPdfClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*HtmlToPdfClient) SetTitle

func (client *HtmlToPdfClient) SetTitle(title string) *HtmlToPdfClient

Set the title of the PDF.

title - The title.

func (*HtmlToPdfClient) SetUseHttp

func (client *HtmlToPdfClient) SetUseHttp(value bool) *HtmlToPdfClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*HtmlToPdfClient) SetUseMobileUserAgent

func (client *HtmlToPdfClient) SetUseMobileUserAgent(value bool) *HtmlToPdfClient

Use a mobile user agent.

value - Set to true to use a mobile user agent.

func (*HtmlToPdfClient) SetUsePrintMedia

func (client *HtmlToPdfClient) SetUsePrintMedia(value bool) *HtmlToPdfClient

Use the print version of the page if available (@media print).

value - Set to true to use the print version of the page.

func (*HtmlToPdfClient) SetUserAgent

func (client *HtmlToPdfClient) SetUserAgent(agent string) *HtmlToPdfClient

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

agent - The user agent string.

func (*HtmlToPdfClient) SetUserPassword

func (client *HtmlToPdfClient) SetUserPassword(password string) *HtmlToPdfClient

Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.

password - The user password.

func (*HtmlToPdfClient) SetVerifySslCertificates

func (client *HtmlToPdfClient) SetVerifySslCertificates(value bool) *HtmlToPdfClient

Do not allow insecure HTTPS connections.

value - Set to true to enable SSL certificate verification.

func (*HtmlToPdfClient) SetViewport

func (client *HtmlToPdfClient) SetViewport(width int, height int) *HtmlToPdfClient

Set the viewport size. The viewport is the user's visible area of the page.

width - Set the viewport width in pixels. The viewport is the user's visible area of the page. The value must be in the range 96-65000. height - Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000. Must be a positive integer number.

func (*HtmlToPdfClient) SetViewportHeight

func (client *HtmlToPdfClient) SetViewportHeight(height int) *HtmlToPdfClient

Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000.

height - Must be a positive integer number.

func (*HtmlToPdfClient) SetViewportWidth

func (client *HtmlToPdfClient) SetViewportWidth(width int) *HtmlToPdfClient

Set the viewport width in pixels. The viewport is the user's visible area of the page.

width - The value must be in the range 96-65000.

func (*HtmlToPdfClient) SetWaitForElement

func (client *HtmlToPdfClient) SetWaitForElement(selectors string) *HtmlToPdfClient

Wait for the specified element in a source document. 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 API license defines the maximum wait time by "Max Delay" parameter.

selectors - One or more CSS selectors separated by commas. The string must not be empty.

func (*HtmlToPdfClient) SetZipFooterFilename

func (client *HtmlToPdfClient) SetZipFooterFilename(filename string) *HtmlToPdfClient

Set the file name of the footer HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.

filename - The file name.

func (*HtmlToPdfClient) SetZipHeaderFilename

func (client *HtmlToPdfClient) SetZipHeaderFilename(filename string) *HtmlToPdfClient

Set the file name of the header HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.

filename - The file name.

func (*HtmlToPdfClient) SetZipMainFilename

func (client *HtmlToPdfClient) SetZipMainFilename(filename string) *HtmlToPdfClient

Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.

filename - The file name.

type ImageToImageClient

type ImageToImageClient struct {
	// contains filtered or unexported fields
}

Conversion from one image format to another image format.

func NewImageToImageClient

func NewImageToImageClient(userName string, apiKey string) ImageToImageClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*ImageToImageClient) ConvertFile

func (client *ImageToImageClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

file - The path to a local file to convert. The file must exist and not be empty.

func (*ImageToImageClient) ConvertFileToFile

func (client *ImageToImageClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

file - The path to a local file to convert. The file must exist and not be empty. filePath - The output file path. The string must not be empty.

func (*ImageToImageClient) ConvertFileToStream

func (client *ImageToImageClient) ConvertFileToStream(file string, outStream io.Writer) error

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

file - The path to a local file to convert. The file must exist and not be empty. outStream - The output stream that will contain the conversion output.

func (*ImageToImageClient) ConvertRawData

func (client *ImageToImageClient) ConvertRawData(data []byte) ([]byte, error)

Convert raw data.

data - The raw content to be converted.

func (*ImageToImageClient) ConvertRawDataToFile

func (client *ImageToImageClient) ConvertRawDataToFile(data []byte, filePath string) error

Convert raw data to a file.

data - The raw content to be converted. filePath - The output file path. The string must not be empty.

func (*ImageToImageClient) ConvertRawDataToStream

func (client *ImageToImageClient) ConvertRawDataToStream(data []byte, outStream io.Writer) error

Convert raw data and write the result to an output stream.

data - The raw content to be converted. outStream - The output stream that will contain the conversion output.

func (*ImageToImageClient) ConvertStream

func (client *ImageToImageClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - The input stream with source data.

func (*ImageToImageClient) ConvertStreamToFile

func (client *ImageToImageClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - The input stream with source data. filePath - The output file path. The string must not be empty.

func (*ImageToImageClient) ConvertStreamToStream

func (client *ImageToImageClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - The input stream with source data. outStream - The output stream that will contain the conversion output.

func (*ImageToImageClient) ConvertUrl

func (client *ImageToImageClient) ConvertUrl(url string) ([]byte, error)

Convert an image.

url - The address of the image to convert. The supported protocols are http:// and https://.

func (*ImageToImageClient) ConvertUrlToFile

func (client *ImageToImageClient) ConvertUrlToFile(url string, filePath string) error

Convert an image and write the result to a local file.

url - The address of the image to convert. The supported protocols are http:// and https://. filePath - The output file path. The string must not be empty.

func (*ImageToImageClient) ConvertUrlToStream

func (client *ImageToImageClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert an image and write the result to an output stream.

url - The address of the image to convert. The supported protocols are http:// and https://. outStream - The output stream that will contain the conversion output.

func (*ImageToImageClient) GetConsumedCreditCount

func (client *ImageToImageClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*ImageToImageClient) GetDebugLogUrl

func (client *ImageToImageClient) GetDebugLogUrl() string

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

func (*ImageToImageClient) GetJobId

func (client *ImageToImageClient) GetJobId() string

Get the job id.

func (*ImageToImageClient) GetOutputSize

func (client *ImageToImageClient) GetOutputSize() int

Get the size of the output in bytes.

func (*ImageToImageClient) GetRemainingCreditCount

func (client *ImageToImageClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*ImageToImageClient) GetVersion

func (client *ImageToImageClient) GetVersion() string

Get the version details.

func (*ImageToImageClient) SetCanvasBackgroundColor

func (client *ImageToImageClient) SetCanvasBackgroundColor(color string) *ImageToImageClient

The canvas background color in RGB or RGBA hexadecimal format. The color fills the entire canvas regardless of margins. If no canvas size is specified and the image format supports background (e.g. PDF, PNG), the background color is applied too.

color - The value must be in RRGGBB or RRGGBBAA hexadecimal format.

func (*ImageToImageClient) SetCanvasDimensions

func (client *ImageToImageClient) SetCanvasDimensions(width string, height string) *ImageToImageClient

Set the output canvas dimensions. If no canvas size is specified, margins are applied as a border around the image.

width - Set the output canvas width. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". height - Set the output canvas height. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetCanvasHeight

func (client *ImageToImageClient) SetCanvasHeight(height string) *ImageToImageClient

Set the output canvas height.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetCanvasSize

func (client *ImageToImageClient) SetCanvasSize(size string) *ImageToImageClient

Set the output canvas size.

size - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.

func (*ImageToImageClient) SetCanvasWidth

func (client *ImageToImageClient) SetCanvasWidth(width string) *ImageToImageClient

Set the output canvas width.

width - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetClientUserAgent

func (client *ImageToImageClient) SetClientUserAgent(agent string) *ImageToImageClient

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

agent - The user agent string.

func (*ImageToImageClient) SetConverterVersion

func (client *ImageToImageClient) SetConverterVersion(version string) *ImageToImageClient

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

version - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.

func (*ImageToImageClient) SetCropArea

func (client *ImageToImageClient) SetCropArea(x string, y string, width string, height string) *ImageToImageClient

Set the content area position and size. The content area enables to specify the part to be converted.

x - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". y - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". width - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". height - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetCropAreaHeight

func (client *ImageToImageClient) SetCropAreaHeight(height string) *ImageToImageClient

Set the height of the content area. It should be at least 1 inch.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetCropAreaWidth

func (client *ImageToImageClient) SetCropAreaWidth(width string) *ImageToImageClient

Set the width of the content area. It should be at least 1 inch.

width - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetCropAreaX

func (client *ImageToImageClient) SetCropAreaX(x string) *ImageToImageClient

Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.

x - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetCropAreaY

func (client *ImageToImageClient) SetCropAreaY(y string) *ImageToImageClient

Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.

y - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetDebugLog

func (client *ImageToImageClient) SetDebugLog(value bool) *ImageToImageClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*ImageToImageClient) SetDpi

func (client *ImageToImageClient) SetDpi(dpi int) *ImageToImageClient

Set the DPI resolution of the input image. The DPI affects margin options specified in points too (e.g. 1 point is equal to 1 pixel in 96 DPI).

dpi - The DPI value.

func (*ImageToImageClient) SetHttpProxy

func (client *ImageToImageClient) SetHttpProxy(proxy string) *ImageToImageClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*ImageToImageClient) SetHttpsProxy

func (client *ImageToImageClient) SetHttpsProxy(proxy string) *ImageToImageClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*ImageToImageClient) SetMarginBottom

func (client *ImageToImageClient) SetMarginBottom(bottom string) *ImageToImageClient

Set the output canvas bottom margin.

bottom - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetMarginLeft

func (client *ImageToImageClient) SetMarginLeft(left string) *ImageToImageClient

Set the output canvas left margin.

left - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetMarginRight

func (client *ImageToImageClient) SetMarginRight(right string) *ImageToImageClient

Set the output canvas right margin.

right - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetMarginTop

func (client *ImageToImageClient) SetMarginTop(top string) *ImageToImageClient

Set the output canvas top margin.

top - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetMargins

func (client *ImageToImageClient) SetMargins(top string, right string, bottom string, left string) *ImageToImageClient

Set the output canvas margins.

top - Set the output canvas top margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". right - Set the output canvas right margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". bottom - Set the output canvas bottom margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". left - Set the output canvas left margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToImageClient) SetOrientation

func (client *ImageToImageClient) SetOrientation(orientation string) *ImageToImageClient

Set the output canvas orientation.

orientation - Allowed values are landscape, portrait.

func (*ImageToImageClient) SetOutputFormat

func (client *ImageToImageClient) SetOutputFormat(outputFormat string) *ImageToImageClient

The format of the output file.

outputFormat - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.

func (*ImageToImageClient) SetPosition

func (client *ImageToImageClient) SetPosition(position string) *ImageToImageClient

Set the image position on the canvas.

position - Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.

func (*ImageToImageClient) SetPrintCanvasMode

func (client *ImageToImageClient) SetPrintCanvasMode(mode string) *ImageToImageClient

Set the mode to print the image on the canvas.

mode - Allowed values are default, fit, stretch.

func (*ImageToImageClient) SetProxy

func (client *ImageToImageClient) SetProxy(host string, port int, userName string, password string) *ImageToImageClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*ImageToImageClient) SetRemoveBorders

func (client *ImageToImageClient) SetRemoveBorders(value bool) *ImageToImageClient

Remove borders of an image which does not change in color.

value - Set to true to remove borders.

func (*ImageToImageClient) SetResize

func (client *ImageToImageClient) SetResize(resize string) *ImageToImageClient

Resize the image.

resize - The resize percentage or new image dimensions.

func (*ImageToImageClient) SetRetryCount

func (client *ImageToImageClient) SetRetryCount(count int) *ImageToImageClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*ImageToImageClient) SetRotate

func (client *ImageToImageClient) SetRotate(rotate string) *ImageToImageClient

Rotate the image.

rotate - The rotation specified in degrees.

func (*ImageToImageClient) SetTag

func (client *ImageToImageClient) SetTag(tag string) *ImageToImageClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*ImageToImageClient) SetUseHttp

func (client *ImageToImageClient) SetUseHttp(value bool) *ImageToImageClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*ImageToImageClient) SetUserAgent

func (client *ImageToImageClient) SetUserAgent(agent string) *ImageToImageClient

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

agent - The user agent string.

type ImageToPdfClient

type ImageToPdfClient struct {
	// contains filtered or unexported fields
}

Conversion from an image to PDF.

func NewImageToPdfClient

func NewImageToPdfClient(userName string, apiKey string) ImageToPdfClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*ImageToPdfClient) ConvertFile

func (client *ImageToPdfClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

file - The path to a local file to convert. The file must exist and not be empty.

func (*ImageToPdfClient) ConvertFileToFile

func (client *ImageToPdfClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

file - The path to a local file to convert. The file must exist and not be empty. filePath - The output file path. The string must not be empty.

func (*ImageToPdfClient) ConvertFileToStream

func (client *ImageToPdfClient) ConvertFileToStream(file string, outStream io.Writer) error

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

file - The path to a local file to convert. The file must exist and not be empty. outStream - The output stream that will contain the conversion output.

func (*ImageToPdfClient) ConvertRawData

func (client *ImageToPdfClient) ConvertRawData(data []byte) ([]byte, error)

Convert raw data.

data - The raw content to be converted.

func (*ImageToPdfClient) ConvertRawDataToFile

func (client *ImageToPdfClient) ConvertRawDataToFile(data []byte, filePath string) error

Convert raw data to a file.

data - The raw content to be converted. filePath - The output file path. The string must not be empty.

func (*ImageToPdfClient) ConvertRawDataToStream

func (client *ImageToPdfClient) ConvertRawDataToStream(data []byte, outStream io.Writer) error

Convert raw data and write the result to an output stream.

data - The raw content to be converted. outStream - The output stream that will contain the conversion output.

func (*ImageToPdfClient) ConvertStream

func (client *ImageToPdfClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - The input stream with source data.

func (*ImageToPdfClient) ConvertStreamToFile

func (client *ImageToPdfClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - The input stream with source data. filePath - The output file path. The string must not be empty.

func (*ImageToPdfClient) ConvertStreamToStream

func (client *ImageToPdfClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - The input stream with source data. outStream - The output stream that will contain the conversion output.

func (*ImageToPdfClient) ConvertUrl

func (client *ImageToPdfClient) ConvertUrl(url string) ([]byte, error)

Convert an image.

url - The address of the image to convert. The supported protocols are http:// and https://.

func (*ImageToPdfClient) ConvertUrlToFile

func (client *ImageToPdfClient) ConvertUrlToFile(url string, filePath string) error

Convert an image and write the result to a local file.

url - The address of the image to convert. The supported protocols are http:// and https://. filePath - The output file path. The string must not be empty.

func (*ImageToPdfClient) ConvertUrlToStream

func (client *ImageToPdfClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert an image and write the result to an output stream.

url - The address of the image to convert. The supported protocols are http:// and https://. outStream - The output stream that will contain the conversion output.

func (*ImageToPdfClient) GetConsumedCreditCount

func (client *ImageToPdfClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*ImageToPdfClient) GetDebugLogUrl

func (client *ImageToPdfClient) GetDebugLogUrl() string

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

func (*ImageToPdfClient) GetJobId

func (client *ImageToPdfClient) GetJobId() string

Get the job id.

func (*ImageToPdfClient) GetOutputSize

func (client *ImageToPdfClient) GetOutputSize() int

Get the size of the output in bytes.

func (*ImageToPdfClient) GetRemainingCreditCount

func (client *ImageToPdfClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*ImageToPdfClient) GetVersion

func (client *ImageToPdfClient) GetVersion() string

Get the version details.

func (*ImageToPdfClient) SetAuthor

func (client *ImageToPdfClient) SetAuthor(author string) *ImageToPdfClient

Set the author of the PDF.

author - The author.

func (*ImageToPdfClient) SetCenterWindow

func (client *ImageToPdfClient) SetCenterWindow(value bool) *ImageToPdfClient

Specify whether to position the document's window in the center of the screen.

value - Set to true to center the window.

func (*ImageToPdfClient) SetClientUserAgent

func (client *ImageToPdfClient) SetClientUserAgent(agent string) *ImageToPdfClient

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

agent - The user agent string.

func (*ImageToPdfClient) SetConverterVersion

func (client *ImageToPdfClient) SetConverterVersion(version string) *ImageToPdfClient

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

version - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.

func (*ImageToPdfClient) SetCropArea

func (client *ImageToPdfClient) SetCropArea(x string, y string, width string, height string) *ImageToPdfClient

Set the content area position and size. The content area enables to specify the part to be converted.

x - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". y - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". width - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". height - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetCropAreaHeight

func (client *ImageToPdfClient) SetCropAreaHeight(height string) *ImageToPdfClient

Set the height of the content area. It should be at least 1 inch.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetCropAreaWidth

func (client *ImageToPdfClient) SetCropAreaWidth(width string) *ImageToPdfClient

Set the width of the content area. It should be at least 1 inch.

width - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetCropAreaX

func (client *ImageToPdfClient) SetCropAreaX(x string) *ImageToPdfClient

Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.

x - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetCropAreaY

func (client *ImageToPdfClient) SetCropAreaY(y string) *ImageToPdfClient

Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.

y - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetDebugLog

func (client *ImageToPdfClient) SetDebugLog(value bool) *ImageToPdfClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*ImageToPdfClient) SetDisplayTitle

func (client *ImageToPdfClient) SetDisplayTitle(value bool) *ImageToPdfClient

Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.

value - Set to true to display the title.

func (*ImageToPdfClient) SetDpi

func (client *ImageToPdfClient) SetDpi(dpi int) *ImageToPdfClient

Set the DPI resolution of the input image. The DPI affects margin options specified in points too (e.g. 1 point is equal to 1 pixel in 96 DPI).

dpi - The DPI value.

func (*ImageToPdfClient) SetEncrypt

func (client *ImageToPdfClient) SetEncrypt(value bool) *ImageToPdfClient

Encrypt the PDF. This prevents search engines from indexing the contents.

value - Set to true to enable PDF encryption.

func (*ImageToPdfClient) SetFitWindow

func (client *ImageToPdfClient) SetFitWindow(value bool) *ImageToPdfClient

Specify whether to resize the document's window to fit the size of the first displayed page.

value - Set to true to resize the window.

func (*ImageToPdfClient) SetHideMenubar

func (client *ImageToPdfClient) SetHideMenubar(value bool) *ImageToPdfClient

Specify whether to hide the viewer application's menu bar when the document is active.

value - Set to true to hide the menu bar.

func (*ImageToPdfClient) SetHideToolbar

func (client *ImageToPdfClient) SetHideToolbar(value bool) *ImageToPdfClient

Specify whether to hide the viewer application's tool bars when the document is active.

value - Set to true to hide tool bars.

func (*ImageToPdfClient) SetHideWindowUi

func (client *ImageToPdfClient) SetHideWindowUi(value bool) *ImageToPdfClient

Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.

value - Set to true to hide ui elements.

func (*ImageToPdfClient) SetHttpProxy

func (client *ImageToPdfClient) SetHttpProxy(proxy string) *ImageToPdfClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*ImageToPdfClient) SetHttpsProxy

func (client *ImageToPdfClient) SetHttpsProxy(proxy string) *ImageToPdfClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*ImageToPdfClient) SetInitialPage

func (client *ImageToPdfClient) SetInitialPage(page int) *ImageToPdfClient

Display the specified page when the document is opened.

page - Must be a positive integer number.

func (*ImageToPdfClient) SetInitialZoom

func (client *ImageToPdfClient) SetInitialZoom(zoom int) *ImageToPdfClient

Specify the initial page zoom in percents when the document is opened.

zoom - Must be a positive integer number.

func (*ImageToPdfClient) SetInitialZoomType

func (client *ImageToPdfClient) SetInitialZoomType(zoomType string) *ImageToPdfClient

Specify how the page should be displayed when opened.

zoomType - Allowed values are fit-width, fit-height, fit-page.

func (*ImageToPdfClient) SetKeywords

func (client *ImageToPdfClient) SetKeywords(keywords string) *ImageToPdfClient

Associate keywords with the document.

keywords - The string with the keywords.

func (*ImageToPdfClient) SetLinearize

func (client *ImageToPdfClient) SetLinearize(value bool) *ImageToPdfClient

Create linearized PDF. This is also known as Fast Web View.

value - Set to true to create linearized PDF.

func (*ImageToPdfClient) SetMarginBottom

func (client *ImageToPdfClient) SetMarginBottom(bottom string) *ImageToPdfClient

Set the output page bottom margin.

bottom - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetMarginLeft

func (client *ImageToPdfClient) SetMarginLeft(left string) *ImageToPdfClient

Set the output page left margin.

left - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetMarginRight

func (client *ImageToPdfClient) SetMarginRight(right string) *ImageToPdfClient

Set the output page right margin.

right - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetMarginTop

func (client *ImageToPdfClient) SetMarginTop(top string) *ImageToPdfClient

Set the output page top margin.

top - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetMultipageBackground

func (client *ImageToPdfClient) SetMultipageBackground(background string) *ImageToPdfClient

Apply each page of a background to the corresponding page of the output PDF. A background can be either a PDF or an image.

background - The file path to a local file. The file must exist and not be empty.

func (*ImageToPdfClient) SetMultipageBackgroundUrl

func (client *ImageToPdfClient) SetMultipageBackgroundUrl(url string) *ImageToPdfClient

Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.

url - The supported protocols are http:// and https://.

func (*ImageToPdfClient) SetMultipageWatermark

func (client *ImageToPdfClient) SetMultipageWatermark(watermark string) *ImageToPdfClient

Apply each page of a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.

watermark - The file path to a local file. The file must exist and not be empty.

func (*ImageToPdfClient) SetMultipageWatermarkUrl

func (client *ImageToPdfClient) SetMultipageWatermarkUrl(url string) *ImageToPdfClient

Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.

url - The supported protocols are http:// and https://.

func (*ImageToPdfClient) SetNoCopy

func (client *ImageToPdfClient) SetNoCopy(value bool) *ImageToPdfClient

Disallow text and graphics extraction from the output PDF.

value - Set to true to set the no-copy flag in the output PDF.

func (*ImageToPdfClient) SetNoModify

func (client *ImageToPdfClient) SetNoModify(value bool) *ImageToPdfClient

Disallow modification of the output PDF.

value - Set to true to set the read-only only flag in the output PDF.

func (*ImageToPdfClient) SetNoPrint

func (client *ImageToPdfClient) SetNoPrint(value bool) *ImageToPdfClient

Disallow printing of the output PDF.

value - Set to true to set the no-print flag in the output PDF.

func (*ImageToPdfClient) SetOrientation

func (client *ImageToPdfClient) SetOrientation(orientation string) *ImageToPdfClient

Set the output page orientation.

orientation - Allowed values are landscape, portrait.

func (*ImageToPdfClient) SetOwnerPassword

func (client *ImageToPdfClient) SetOwnerPassword(password string) *ImageToPdfClient

Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.

password - The owner password.

func (*ImageToPdfClient) SetPageBackground

func (client *ImageToPdfClient) SetPageBackground(background string) *ImageToPdfClient

Apply a background to each page of the output PDF file. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.

background - The file path to a local file. The file must exist and not be empty.

func (*ImageToPdfClient) SetPageBackgroundColor

func (client *ImageToPdfClient) SetPageBackgroundColor(color string) *ImageToPdfClient

The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins. If not page size is specified and the image format supports background (e.g. PDF, PNG), the background color is applied too.

color - The value must be in RRGGBB or RRGGBBAA hexadecimal format.

func (*ImageToPdfClient) SetPageBackgroundUrl

func (client *ImageToPdfClient) SetPageBackgroundUrl(url string) *ImageToPdfClient

Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.

url - The supported protocols are http:// and https://.

func (*ImageToPdfClient) SetPageDimensions

func (client *ImageToPdfClient) SetPageDimensions(width string, height string) *ImageToPdfClient

Set the output page dimensions. If no page size is specified, margins are applied as a border around the image.

width - Set the output page width. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". height - Set the output page height. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetPageHeight

func (client *ImageToPdfClient) SetPageHeight(height string) *ImageToPdfClient

Set the output page height.

height - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetPageLayout

func (client *ImageToPdfClient) SetPageLayout(layout string) *ImageToPdfClient

Specify the page layout to be used when the document is opened.

layout - Allowed values are single-page, one-column, two-column-left, two-column-right.

func (*ImageToPdfClient) SetPageMargins

func (client *ImageToPdfClient) SetPageMargins(top string, right string, bottom string, left string) *ImageToPdfClient

Set the output page margins.

top - Set the output page top margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". right - Set the output page right margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". bottom - Set the output page bottom margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". left - Set the output page left margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetPageMode

func (client *ImageToPdfClient) SetPageMode(mode string) *ImageToPdfClient

Specify how the document should be displayed when opened.

mode - Allowed values are full-screen, thumbnails, outlines.

func (*ImageToPdfClient) SetPageSize

func (client *ImageToPdfClient) SetPageSize(size string) *ImageToPdfClient

Set the output page size.

size - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.

func (*ImageToPdfClient) SetPageWatermark

func (client *ImageToPdfClient) SetPageWatermark(watermark string) *ImageToPdfClient

Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.

watermark - The file path to a local file. The file must exist and not be empty.

func (*ImageToPdfClient) SetPageWatermarkUrl

func (client *ImageToPdfClient) SetPageWatermarkUrl(url string) *ImageToPdfClient

Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.

url - The supported protocols are http:// and https://.

func (*ImageToPdfClient) SetPageWidth

func (client *ImageToPdfClient) SetPageWidth(width string) *ImageToPdfClient

Set the output page width.

width - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".

func (*ImageToPdfClient) SetPosition

func (client *ImageToPdfClient) SetPosition(position string) *ImageToPdfClient

Set the image position on the page.

position - Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.

func (*ImageToPdfClient) SetPrintPageMode

func (client *ImageToPdfClient) SetPrintPageMode(mode string) *ImageToPdfClient

Set the mode to print the image on the content area of the page.

mode - Allowed values are default, fit, stretch.

func (*ImageToPdfClient) SetProxy

func (client *ImageToPdfClient) SetProxy(host string, port int, userName string, password string) *ImageToPdfClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*ImageToPdfClient) SetRemoveBorders

func (client *ImageToPdfClient) SetRemoveBorders(value bool) *ImageToPdfClient

Remove borders of an image which does not change in color.

value - Set to true to remove borders.

func (*ImageToPdfClient) SetResize

func (client *ImageToPdfClient) SetResize(resize string) *ImageToPdfClient

Resize the image.

resize - The resize percentage or new image dimensions.

func (*ImageToPdfClient) SetRetryCount

func (client *ImageToPdfClient) SetRetryCount(count int) *ImageToPdfClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*ImageToPdfClient) SetRotate

func (client *ImageToPdfClient) SetRotate(rotate string) *ImageToPdfClient

Rotate the image.

rotate - The rotation specified in degrees.

func (*ImageToPdfClient) SetSubject

func (client *ImageToPdfClient) SetSubject(subject string) *ImageToPdfClient

Set the subject of the PDF.

subject - The subject.

func (*ImageToPdfClient) SetTag

func (client *ImageToPdfClient) SetTag(tag string) *ImageToPdfClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*ImageToPdfClient) SetTitle

func (client *ImageToPdfClient) SetTitle(title string) *ImageToPdfClient

Set the title of the PDF.

title - The title.

func (*ImageToPdfClient) SetUseHttp

func (client *ImageToPdfClient) SetUseHttp(value bool) *ImageToPdfClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*ImageToPdfClient) SetUserAgent

func (client *ImageToPdfClient) SetUserAgent(agent string) *ImageToPdfClient

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

agent - The user agent string.

func (*ImageToPdfClient) SetUserPassword

func (client *ImageToPdfClient) SetUserPassword(password string) *ImageToPdfClient

Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.

password - The user password.

type PdfToHtmlClient

type PdfToHtmlClient struct {
	// contains filtered or unexported fields
}

Conversion from PDF to HTML.

func NewPdfToHtmlClient

func NewPdfToHtmlClient(userName string, apiKey string) PdfToHtmlClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*PdfToHtmlClient) ConvertFile

func (client *PdfToHtmlClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

file - The path to a local file to convert. The file must exist and not be empty.

func (*PdfToHtmlClient) ConvertFileToFile

func (client *PdfToHtmlClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

file - The path to a local file to convert. The file must exist and not be empty. filePath - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.

func (*PdfToHtmlClient) ConvertFileToStream

func (client *PdfToHtmlClient) ConvertFileToStream(file string, outStream io.Writer) error

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

file - The path to a local file to convert. The file must exist and not be empty. outStream - The output stream that will contain the conversion output.

func (*PdfToHtmlClient) ConvertRawData

func (client *PdfToHtmlClient) ConvertRawData(data []byte) ([]byte, error)

Convert raw data.

data - The raw content to be converted.

func (*PdfToHtmlClient) ConvertRawDataToFile

func (client *PdfToHtmlClient) ConvertRawDataToFile(data []byte, filePath string) error

Convert raw data to a file.

data - The raw content to be converted. filePath - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.

func (*PdfToHtmlClient) ConvertRawDataToStream

func (client *PdfToHtmlClient) ConvertRawDataToStream(data []byte, outStream io.Writer) error

Convert raw data and write the result to an output stream.

data - The raw content to be converted. outStream - The output stream that will contain the conversion output.

func (*PdfToHtmlClient) ConvertStream

func (client *PdfToHtmlClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - The input stream with source data.

func (*PdfToHtmlClient) ConvertStreamToFile

func (client *PdfToHtmlClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - The input stream with source data. filePath - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.

func (*PdfToHtmlClient) ConvertStreamToStream

func (client *PdfToHtmlClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - The input stream with source data. outStream - The output stream that will contain the conversion output.

func (*PdfToHtmlClient) ConvertUrl

func (client *PdfToHtmlClient) ConvertUrl(url string) ([]byte, error)

Convert a PDF.

url - The address of the PDF to convert. The supported protocols are http:// and https://.

func (*PdfToHtmlClient) ConvertUrlToFile

func (client *PdfToHtmlClient) ConvertUrlToFile(url string, filePath string) error

Convert a PDF and write the result to a local file.

url - The address of the PDF to convert. The supported protocols are http:// and https://. filePath - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.

func (*PdfToHtmlClient) ConvertUrlToStream

func (client *PdfToHtmlClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert a PDF and write the result to an output stream.

url - The address of the PDF to convert. The supported protocols are http:// and https://. outStream - The output stream that will contain the conversion output.

func (*PdfToHtmlClient) GetConsumedCreditCount

func (client *PdfToHtmlClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*PdfToHtmlClient) GetDebugLogUrl

func (client *PdfToHtmlClient) GetDebugLogUrl() string

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

func (*PdfToHtmlClient) GetJobId

func (client *PdfToHtmlClient) GetJobId() string

Get the job id.

func (*PdfToHtmlClient) GetOutputSize

func (client *PdfToHtmlClient) GetOutputSize() int

Get the size of the output in bytes.

func (*PdfToHtmlClient) GetPageCount

func (client *PdfToHtmlClient) GetPageCount() int

Get the number of pages in the output document.

func (*PdfToHtmlClient) GetRemainingCreditCount

func (client *PdfToHtmlClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*PdfToHtmlClient) GetVersion

func (client *PdfToHtmlClient) GetVersion() string

Get the version details.

func (*PdfToHtmlClient) IsZippedOutput

func (client *PdfToHtmlClient) IsZippedOutput() bool

A helper method to determine if the output file is a zip archive. The output of the conversion may be either an HTML file or a zip file containing the HTML and its external assets.

func (*PdfToHtmlClient) SetAuthor

func (client *PdfToHtmlClient) SetAuthor(author string) *PdfToHtmlClient

Set the HTML author. The author from the input PDF is used by default.

author - The HTML author.

func (*PdfToHtmlClient) SetClientUserAgent

func (client *PdfToHtmlClient) SetClientUserAgent(agent string) *PdfToHtmlClient

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

agent - The user agent string.

func (*PdfToHtmlClient) SetConverterVersion

func (client *PdfToHtmlClient) SetConverterVersion(version string) *PdfToHtmlClient

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

version - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.

func (*PdfToHtmlClient) SetCssMode

func (client *PdfToHtmlClient) SetCssMode(mode string) *PdfToHtmlClient

Specifies where the style sheets are stored.

mode - The style sheet storage mode. Allowed values are embed, separate.

func (*PdfToHtmlClient) SetCustomCss

func (client *PdfToHtmlClient) SetCustomCss(css string) *PdfToHtmlClient

Apply custom CSS to the output HTML document. It allows you to modify the visual appearance and layout. Tip: Using !important in custom CSS provides a way to prioritize and override conflicting styles.

css - A string containing valid CSS. The string must not be empty.

func (*PdfToHtmlClient) SetDebugLog

func (client *PdfToHtmlClient) SetDebugLog(value bool) *PdfToHtmlClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*PdfToHtmlClient) SetDpi

func (client *PdfToHtmlClient) SetDpi(dpi int) *PdfToHtmlClient

Set the output graphics DPI.

dpi - The DPI value.

func (*PdfToHtmlClient) SetFontMode

func (client *PdfToHtmlClient) SetFontMode(mode string) *PdfToHtmlClient

Specifies where the fonts are stored.

mode - The font storage mode. Allowed values are embed, separate.

func (*PdfToHtmlClient) SetForceZip

func (client *PdfToHtmlClient) SetForceZip(value bool) *PdfToHtmlClient

Enforces the zip output format.

value - Set to true to get the output as a zip archive.

func (*PdfToHtmlClient) SetHtmlNamespace

func (client *PdfToHtmlClient) SetHtmlNamespace(prefix string) *PdfToHtmlClient

Add the specified prefix to all id and class attributes in the HTML content, creating a namespace for safe integration into another HTML document. This ensures unique identifiers, preventing conflicts when merging with other HTML.

prefix - The prefix to add before each id and class attribute name. Start with a letter or underscore, and use only letters, numbers, hyphens, underscores, or colons.

func (*PdfToHtmlClient) SetHttpProxy

func (client *PdfToHtmlClient) SetHttpProxy(proxy string) *PdfToHtmlClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*PdfToHtmlClient) SetHttpsProxy

func (client *PdfToHtmlClient) SetHttpsProxy(proxy string) *PdfToHtmlClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*PdfToHtmlClient) SetImageFormat

func (client *PdfToHtmlClient) SetImageFormat(imageFormat string) *PdfToHtmlClient

Specifies the format for the output images.

imageFormat - The image format. Allowed values are png, jpg, svg.

func (*PdfToHtmlClient) SetImageMode

func (client *PdfToHtmlClient) SetImageMode(mode string) *PdfToHtmlClient

Specifies where the images are stored.

mode - The image storage mode. Allowed values are embed, separate, none.

func (*PdfToHtmlClient) SetKeywords

func (client *PdfToHtmlClient) SetKeywords(keywords string) *PdfToHtmlClient

Associate keywords with the HTML document. Keywords from the input PDF are used by default.

keywords - The string containing the keywords.

func (*PdfToHtmlClient) SetPdfPassword

func (client *PdfToHtmlClient) SetPdfPassword(password string) *PdfToHtmlClient

Password to open the encrypted PDF file.

password - The input PDF password.

func (*PdfToHtmlClient) SetPrintPageRange

func (client *PdfToHtmlClient) SetPrintPageRange(pages string) *PdfToHtmlClient

Set the page range to print.

pages - A comma separated list of page numbers or ranges.

func (*PdfToHtmlClient) SetProxy

func (client *PdfToHtmlClient) SetProxy(host string, port int, userName string, password string) *PdfToHtmlClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*PdfToHtmlClient) SetRetryCount

func (client *PdfToHtmlClient) SetRetryCount(count int) *PdfToHtmlClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*PdfToHtmlClient) SetScaleFactor

func (client *PdfToHtmlClient) SetScaleFactor(factor int) *PdfToHtmlClient

Set the scaling factor (zoom) for the main page area.

factor - The percentage value. Must be a positive integer number.

func (*PdfToHtmlClient) SetSplitLigatures

func (client *PdfToHtmlClient) SetSplitLigatures(value bool) *PdfToHtmlClient

Converts ligatures, two or more letters combined into a single glyph, back into their individual ASCII characters.

value - Set to true to split ligatures.

func (*PdfToHtmlClient) SetSubject

func (client *PdfToHtmlClient) SetSubject(subject string) *PdfToHtmlClient

Set the HTML subject. The subject from the input PDF is used by default.

subject - The HTML subject.

func (*PdfToHtmlClient) SetTag

func (client *PdfToHtmlClient) SetTag(tag string) *PdfToHtmlClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*PdfToHtmlClient) SetTitle

func (client *PdfToHtmlClient) SetTitle(title string) *PdfToHtmlClient

Set the HTML title. The title from the input PDF is used by default.

title - The HTML title.

func (*PdfToHtmlClient) SetType3Mode

func (client *PdfToHtmlClient) SetType3Mode(mode string) *PdfToHtmlClient

Sets the processing mode for handling Type 3 fonts.

mode - The type3 font mode. Allowed values are raster, convert.

func (*PdfToHtmlClient) SetUseHttp

func (client *PdfToHtmlClient) SetUseHttp(value bool) *PdfToHtmlClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*PdfToHtmlClient) SetUserAgent

func (client *PdfToHtmlClient) SetUserAgent(agent string) *PdfToHtmlClient

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

agent - The user agent string.

type PdfToImageClient

type PdfToImageClient struct {
	// contains filtered or unexported fields
}

Conversion from PDF to image.

func NewPdfToImageClient

func NewPdfToImageClient(userName string, apiKey string) PdfToImageClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*PdfToImageClient) ConvertFile

func (client *PdfToImageClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

file - The path to a local file to convert. The file must exist and not be empty.

func (*PdfToImageClient) ConvertFileToFile

func (client *PdfToImageClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

file - The path to a local file to convert. The file must exist and not be empty. filePath - The output file path. The string must not be empty.

func (*PdfToImageClient) ConvertFileToStream

func (client *PdfToImageClient) ConvertFileToStream(file string, outStream io.Writer) error

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

file - The path to a local file to convert. The file must exist and not be empty. outStream - The output stream that will contain the conversion output.

func (*PdfToImageClient) ConvertRawData

func (client *PdfToImageClient) ConvertRawData(data []byte) ([]byte, error)

Convert raw data.

data - The raw content to be converted.

func (*PdfToImageClient) ConvertRawDataToFile

func (client *PdfToImageClient) ConvertRawDataToFile(data []byte, filePath string) error

Convert raw data to a file.

data - The raw content to be converted. filePath - The output file path. The string must not be empty.

func (*PdfToImageClient) ConvertRawDataToStream

func (client *PdfToImageClient) ConvertRawDataToStream(data []byte, outStream io.Writer) error

Convert raw data and write the result to an output stream.

data - The raw content to be converted. outStream - The output stream that will contain the conversion output.

func (*PdfToImageClient) ConvertStream

func (client *PdfToImageClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - The input stream with source data.

func (*PdfToImageClient) ConvertStreamToFile

func (client *PdfToImageClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - The input stream with source data. filePath - The output file path. The string must not be empty.

func (*PdfToImageClient) ConvertStreamToStream

func (client *PdfToImageClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - The input stream with source data. outStream - The output stream that will contain the conversion output.

func (*PdfToImageClient) ConvertUrl

func (client *PdfToImageClient) ConvertUrl(url string) ([]byte, error)

Convert an image.

url - The address of the image to convert. The supported protocols are http:// and https://.

func (*PdfToImageClient) ConvertUrlToFile

func (client *PdfToImageClient) ConvertUrlToFile(url string, filePath string) error

Convert an image and write the result to a local file.

url - The address of the image to convert. The supported protocols are http:// and https://. filePath - The output file path. The string must not be empty.

func (*PdfToImageClient) ConvertUrlToStream

func (client *PdfToImageClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert an image and write the result to an output stream.

url - The address of the image to convert. The supported protocols are http:// and https://. outStream - The output stream that will contain the conversion output.

func (*PdfToImageClient) GetConsumedCreditCount

func (client *PdfToImageClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*PdfToImageClient) GetDebugLogUrl

func (client *PdfToImageClient) GetDebugLogUrl() string

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

func (*PdfToImageClient) GetJobId

func (client *PdfToImageClient) GetJobId() string

Get the job id.

func (*PdfToImageClient) GetOutputSize

func (client *PdfToImageClient) GetOutputSize() int

Get the size of the output in bytes.

func (*PdfToImageClient) GetPageCount

func (client *PdfToImageClient) GetPageCount() int

Get the number of pages in the output document.

func (*PdfToImageClient) GetRemainingCreditCount

func (client *PdfToImageClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*PdfToImageClient) GetVersion

func (client *PdfToImageClient) GetVersion() string

Get the version details.

func (*PdfToImageClient) IsZippedOutput

func (client *PdfToImageClient) IsZippedOutput() bool

A helper method to determine if the output file from a conversion process is a zip archive. The conversion output can be either a single image file or a zip file containing one or more image files. This method should be called after the conversion has been successfully completed.

func (*PdfToImageClient) SetClientUserAgent

func (client *PdfToImageClient) SetClientUserAgent(agent string) *PdfToImageClient

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

agent - The user agent string.

func (*PdfToImageClient) SetCropArea

func (client *PdfToImageClient) SetCropArea(x int, y int, width int, height int) *PdfToImageClient

Set the crop area. It allows to extract just a part of a PDF page.

x - Set the top left X coordinate of the crop area in points. Must be a positive integer number or 0. y - Set the top left Y coordinate of the crop area in points. Must be a positive integer number or 0. width - Set the width of the crop area in points. Must be a positive integer number or 0. height - Set the height of the crop area in points. Must be a positive integer number or 0.

func (*PdfToImageClient) SetCropAreaHeight

func (client *PdfToImageClient) SetCropAreaHeight(height int) *PdfToImageClient

Set the height of the crop area in points.

height - Must be a positive integer number or 0.

func (*PdfToImageClient) SetCropAreaWidth

func (client *PdfToImageClient) SetCropAreaWidth(width int) *PdfToImageClient

Set the width of the crop area in points.

width - Must be a positive integer number or 0.

func (*PdfToImageClient) SetCropAreaX

func (client *PdfToImageClient) SetCropAreaX(x int) *PdfToImageClient

Set the top left X coordinate of the crop area in points.

x - Must be a positive integer number or 0.

func (*PdfToImageClient) SetCropAreaY

func (client *PdfToImageClient) SetCropAreaY(y int) *PdfToImageClient

Set the top left Y coordinate of the crop area in points.

y - Must be a positive integer number or 0.

func (*PdfToImageClient) SetDebugLog

func (client *PdfToImageClient) SetDebugLog(value bool) *PdfToImageClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*PdfToImageClient) SetDpi

func (client *PdfToImageClient) SetDpi(dpi int) *PdfToImageClient

Set the output graphics DPI.

dpi - The DPI value.

func (*PdfToImageClient) SetForceZip

func (client *PdfToImageClient) SetForceZip(value bool) *PdfToImageClient

Enforces the zip output format.

value - Set to true to get the output as a zip archive.

func (*PdfToImageClient) SetHttpProxy

func (client *PdfToImageClient) SetHttpProxy(proxy string) *PdfToImageClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*PdfToImageClient) SetHttpsProxy

func (client *PdfToImageClient) SetHttpsProxy(proxy string) *PdfToImageClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*PdfToImageClient) SetOutputFormat

func (client *PdfToImageClient) SetOutputFormat(outputFormat string) *PdfToImageClient

The format of the output file.

outputFormat - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.

func (*PdfToImageClient) SetPdfPassword

func (client *PdfToImageClient) SetPdfPassword(password string) *PdfToImageClient

Password to open the encrypted PDF file.

password - The input PDF password.

func (*PdfToImageClient) SetPrintPageRange

func (client *PdfToImageClient) SetPrintPageRange(pages string) *PdfToImageClient

Set the page range to print.

pages - A comma separated list of page numbers or ranges.

func (*PdfToImageClient) SetProxy

func (client *PdfToImageClient) SetProxy(host string, port int, userName string, password string) *PdfToImageClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*PdfToImageClient) SetRetryCount

func (client *PdfToImageClient) SetRetryCount(count int) *PdfToImageClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*PdfToImageClient) SetTag

func (client *PdfToImageClient) SetTag(tag string) *PdfToImageClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*PdfToImageClient) SetUseCropbox

func (client *PdfToImageClient) SetUseCropbox(value bool) *PdfToImageClient

Use the crop box rather than media box.

value - Set to true to use crop box.

func (*PdfToImageClient) SetUseGrayscale

func (client *PdfToImageClient) SetUseGrayscale(value bool) *PdfToImageClient

Generate a grayscale image.

value - Set to true to generate a grayscale image.

func (*PdfToImageClient) SetUseHttp

func (client *PdfToImageClient) SetUseHttp(value bool) *PdfToImageClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*PdfToImageClient) SetUserAgent

func (client *PdfToImageClient) SetUserAgent(agent string) *PdfToImageClient

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

agent - The user agent string.

type PdfToPdfClient

type PdfToPdfClient struct {
	// contains filtered or unexported fields
}

Conversion from PDF to PDF.

func NewPdfToPdfClient

func NewPdfToPdfClient(userName string, apiKey string) PdfToPdfClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*PdfToPdfClient) AddPdfFile

func (client *PdfToPdfClient) AddPdfFile(filePath string) *PdfToPdfClient

Add a PDF file to the list of the input PDFs.

filePath - The file path to a local PDF file. The file must exist and not be empty.

func (*PdfToPdfClient) AddPdfRawData

func (client *PdfToPdfClient) AddPdfRawData(data []byte) *PdfToPdfClient

Add in-memory raw PDF data to the list of the input PDFs.Typical usage is for adding PDF created by another Pdfcrowd converter. Example in PHP: $clientPdf2Pdf->addPdfRawData($clientHtml2Pdf->convertUrl('http://www.example.com'));

data - The raw PDF data. The input data must be PDF content.

func (*PdfToPdfClient) Convert

func (client *PdfToPdfClient) Convert() ([]byte, error)

Perform an action on the input files.

func (*PdfToPdfClient) ConvertToFile

func (client *PdfToPdfClient) ConvertToFile(filePath string) error

Perform an action on the input files and write the output PDF to a file.

filePath - The output file path. The string must not be empty.

func (*PdfToPdfClient) ConvertToStream

func (client *PdfToPdfClient) ConvertToStream(outStream io.Writer) error

Perform an action on the input files and write the output PDF to an output stream.

outStream - The output stream that will contain the output PDF.

func (*PdfToPdfClient) GetConsumedCreditCount

func (client *PdfToPdfClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*PdfToPdfClient) GetDebugLogUrl

func (client *PdfToPdfClient) GetDebugLogUrl() string

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

func (*PdfToPdfClient) GetJobId

func (client *PdfToPdfClient) GetJobId() string

Get the job id.

func (*PdfToPdfClient) GetOutputSize

func (client *PdfToPdfClient) GetOutputSize() int

Get the size of the output in bytes.

func (*PdfToPdfClient) GetPageCount

func (client *PdfToPdfClient) GetPageCount() int

Get the number of pages in the output document.

func (*PdfToPdfClient) GetRemainingCreditCount

func (client *PdfToPdfClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*PdfToPdfClient) GetVersion

func (client *PdfToPdfClient) GetVersion() string

Get the version details.

func (*PdfToPdfClient) SetAction

func (client *PdfToPdfClient) SetAction(action string) *PdfToPdfClient

Specifies the action to be performed on the input PDFs.

action - Allowed values are join, shuffle, extract, delete.

func (*PdfToPdfClient) SetAuthor

func (client *PdfToPdfClient) SetAuthor(author string) *PdfToPdfClient

Set the author of the PDF.

author - The author.

func (*PdfToPdfClient) SetCenterWindow

func (client *PdfToPdfClient) SetCenterWindow(value bool) *PdfToPdfClient

Specify whether to position the document's window in the center of the screen.

value - Set to true to center the window.

func (*PdfToPdfClient) SetClientUserAgent

func (client *PdfToPdfClient) SetClientUserAgent(agent string) *PdfToPdfClient

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

agent - The user agent string.

func (*PdfToPdfClient) SetConverterVersion

func (client *PdfToPdfClient) SetConverterVersion(version string) *PdfToPdfClient

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

version - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.

func (*PdfToPdfClient) SetDebugLog

func (client *PdfToPdfClient) SetDebugLog(value bool) *PdfToPdfClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*PdfToPdfClient) SetDisplayTitle

func (client *PdfToPdfClient) SetDisplayTitle(value bool) *PdfToPdfClient

Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.

value - Set to true to display the title.

func (*PdfToPdfClient) SetEncrypt

func (client *PdfToPdfClient) SetEncrypt(value bool) *PdfToPdfClient

Encrypt the PDF. This prevents search engines from indexing the contents.

value - Set to true to enable PDF encryption.

func (*PdfToPdfClient) SetFitWindow

func (client *PdfToPdfClient) SetFitWindow(value bool) *PdfToPdfClient

Specify whether to resize the document's window to fit the size of the first displayed page.

value - Set to true to resize the window.

func (*PdfToPdfClient) SetHideMenubar

func (client *PdfToPdfClient) SetHideMenubar(value bool) *PdfToPdfClient

Specify whether to hide the viewer application's menu bar when the document is active.

value - Set to true to hide the menu bar.

func (*PdfToPdfClient) SetHideToolbar

func (client *PdfToPdfClient) SetHideToolbar(value bool) *PdfToPdfClient

Specify whether to hide the viewer application's tool bars when the document is active.

value - Set to true to hide tool bars.

func (*PdfToPdfClient) SetHideWindowUi

func (client *PdfToPdfClient) SetHideWindowUi(value bool) *PdfToPdfClient

Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.

value - Set to true to hide ui elements.

func (*PdfToPdfClient) SetInitialPage

func (client *PdfToPdfClient) SetInitialPage(page int) *PdfToPdfClient

Display the specified page when the document is opened.

page - Must be a positive integer number.

func (*PdfToPdfClient) SetInitialZoom

func (client *PdfToPdfClient) SetInitialZoom(zoom int) *PdfToPdfClient

Specify the initial page zoom in percents when the document is opened.

zoom - Must be a positive integer number.

func (*PdfToPdfClient) SetInitialZoomType

func (client *PdfToPdfClient) SetInitialZoomType(zoomType string) *PdfToPdfClient

Specify how the page should be displayed when opened.

zoomType - Allowed values are fit-width, fit-height, fit-page.

func (*PdfToPdfClient) SetInputPdfPassword

func (client *PdfToPdfClient) SetInputPdfPassword(password string) *PdfToPdfClient

Password to open the encrypted PDF file.

password - The input PDF password.

func (*PdfToPdfClient) SetKeywords

func (client *PdfToPdfClient) SetKeywords(keywords string) *PdfToPdfClient

Associate keywords with the document.

keywords - The string with the keywords.

func (*PdfToPdfClient) SetLinearize

func (client *PdfToPdfClient) SetLinearize(value bool) *PdfToPdfClient

Create linearized PDF. This is also known as Fast Web View.

value - Set to true to create linearized PDF.

func (*PdfToPdfClient) SetMultipageBackground

func (client *PdfToPdfClient) SetMultipageBackground(background string) *PdfToPdfClient

Apply each page of a background to the corresponding page of the output PDF. A background can be either a PDF or an image.

background - The file path to a local file. The file must exist and not be empty.

func (*PdfToPdfClient) SetMultipageBackgroundUrl

func (client *PdfToPdfClient) SetMultipageBackgroundUrl(url string) *PdfToPdfClient

Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.

url - The supported protocols are http:// and https://.

func (*PdfToPdfClient) SetMultipageWatermark

func (client *PdfToPdfClient) SetMultipageWatermark(watermark string) *PdfToPdfClient

Apply each page of a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.

watermark - The file path to a local file. The file must exist and not be empty.

func (*PdfToPdfClient) SetMultipageWatermarkUrl

func (client *PdfToPdfClient) SetMultipageWatermarkUrl(url string) *PdfToPdfClient

Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.

url - The supported protocols are http:// and https://.

func (*PdfToPdfClient) SetNoCopy

func (client *PdfToPdfClient) SetNoCopy(value bool) *PdfToPdfClient

Disallow text and graphics extraction from the output PDF.

value - Set to true to set the no-copy flag in the output PDF.

func (*PdfToPdfClient) SetNoModify

func (client *PdfToPdfClient) SetNoModify(value bool) *PdfToPdfClient

Disallow modification of the output PDF.

value - Set to true to set the read-only only flag in the output PDF.

func (*PdfToPdfClient) SetNoPrint

func (client *PdfToPdfClient) SetNoPrint(value bool) *PdfToPdfClient

Disallow printing of the output PDF.

value - Set to true to set the no-print flag in the output PDF.

func (*PdfToPdfClient) SetOwnerPassword

func (client *PdfToPdfClient) SetOwnerPassword(password string) *PdfToPdfClient

Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.

password - The owner password.

func (*PdfToPdfClient) SetPageBackground

func (client *PdfToPdfClient) SetPageBackground(background string) *PdfToPdfClient

Apply a background to each page of the output PDF file. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.

background - The file path to a local file. The file must exist and not be empty.

func (*PdfToPdfClient) SetPageBackgroundUrl

func (client *PdfToPdfClient) SetPageBackgroundUrl(url string) *PdfToPdfClient

Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.

url - The supported protocols are http:// and https://.

func (*PdfToPdfClient) SetPageLayout

func (client *PdfToPdfClient) SetPageLayout(layout string) *PdfToPdfClient

Specify the page layout to be used when the document is opened.

layout - Allowed values are single-page, one-column, two-column-left, two-column-right.

func (*PdfToPdfClient) SetPageMode

func (client *PdfToPdfClient) SetPageMode(mode string) *PdfToPdfClient

Specify how the document should be displayed when opened.

mode - Allowed values are full-screen, thumbnails, outlines.

func (*PdfToPdfClient) SetPageRange

func (client *PdfToPdfClient) SetPageRange(pages string) *PdfToPdfClient

Set the page range for extract or delete action.

pages - A comma separated list of page numbers or ranges.

func (*PdfToPdfClient) SetPageWatermark

func (client *PdfToPdfClient) SetPageWatermark(watermark string) *PdfToPdfClient

Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.

watermark - The file path to a local file. The file must exist and not be empty.

func (*PdfToPdfClient) SetPageWatermarkUrl

func (client *PdfToPdfClient) SetPageWatermarkUrl(url string) *PdfToPdfClient

Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.

url - The supported protocols are http:// and https://.

func (*PdfToPdfClient) SetProxy

func (client *PdfToPdfClient) SetProxy(host string, port int, userName string, password string) *PdfToPdfClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*PdfToPdfClient) SetRetryCount

func (client *PdfToPdfClient) SetRetryCount(count int) *PdfToPdfClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*PdfToPdfClient) SetRightToLeft

func (client *PdfToPdfClient) SetRightToLeft(value bool) *PdfToPdfClient

Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up

value - Set to true to set right-to-left reading order.

func (*PdfToPdfClient) SetSubject

func (client *PdfToPdfClient) SetSubject(subject string) *PdfToPdfClient

Set the subject of the PDF.

subject - The subject.

func (*PdfToPdfClient) SetTag

func (client *PdfToPdfClient) SetTag(tag string) *PdfToPdfClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*PdfToPdfClient) SetTitle

func (client *PdfToPdfClient) SetTitle(title string) *PdfToPdfClient

Set the title of the PDF.

title - The title.

func (*PdfToPdfClient) SetUseHttp

func (client *PdfToPdfClient) SetUseHttp(value bool) *PdfToPdfClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*PdfToPdfClient) SetUseMetadataFrom

func (client *PdfToPdfClient) SetUseMetadataFrom(index int) *PdfToPdfClient

Use metadata (title, subject, author and keywords) from the n-th input PDF.

index - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer number or 0.

func (*PdfToPdfClient) SetUserAgent

func (client *PdfToPdfClient) SetUserAgent(agent string) *PdfToPdfClient

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

agent - The user agent string.

func (*PdfToPdfClient) SetUserPassword

func (client *PdfToPdfClient) SetUserPassword(password string) *PdfToPdfClient

Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.

password - The user password.

type PdfToTextClient

type PdfToTextClient struct {
	// contains filtered or unexported fields
}

Conversion from PDF to text.

func NewPdfToTextClient

func NewPdfToTextClient(userName string, apiKey string) PdfToTextClient

Constructor for the Pdfcrowd API client.

userName - Your username at Pdfcrowd. apiKey - Your API key.

func (*PdfToTextClient) ConvertFile

func (client *PdfToTextClient) ConvertFile(file string) ([]byte, error)

Convert a local file.

file - The path to a local file to convert. The file must exist and not be empty.

func (*PdfToTextClient) ConvertFileToFile

func (client *PdfToTextClient) ConvertFileToFile(file string, filePath string) error

Convert a local file and write the result to a local file.

file - The path to a local file to convert. The file must exist and not be empty. filePath - The output file path. The string must not be empty.

func (*PdfToTextClient) ConvertFileToStream

func (client *PdfToTextClient) ConvertFileToStream(file string, outStream io.Writer) error

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

file - The path to a local file to convert. The file must exist and not be empty. outStream - The output stream that will contain the conversion output.

func (*PdfToTextClient) ConvertRawData

func (client *PdfToTextClient) ConvertRawData(data []byte) ([]byte, error)

Convert raw data.

data - The raw content to be converted.

func (*PdfToTextClient) ConvertRawDataToFile

func (client *PdfToTextClient) ConvertRawDataToFile(data []byte, filePath string) error

Convert raw data to a file.

data - The raw content to be converted. filePath - The output file path. The string must not be empty.

func (*PdfToTextClient) ConvertRawDataToStream

func (client *PdfToTextClient) ConvertRawDataToStream(data []byte, outStream io.Writer) error

Convert raw data and write the result to an output stream.

data - The raw content to be converted. outStream - The output stream that will contain the conversion output.

func (*PdfToTextClient) ConvertStream

func (client *PdfToTextClient) ConvertStream(inStream io.Reader) ([]byte, error)

Convert the contents of an input stream.

inStream - The input stream with source data.

func (*PdfToTextClient) ConvertStreamToFile

func (client *PdfToTextClient) ConvertStreamToFile(inStream io.Reader, filePath string) error

Convert the contents of an input stream and write the result to a local file.

inStream - The input stream with source data. filePath - The output file path. The string must not be empty.

func (*PdfToTextClient) ConvertStreamToStream

func (client *PdfToTextClient) ConvertStreamToStream(inStream io.Reader, outStream io.Writer) error

Convert the contents of an input stream and write the result to an output stream.

inStream - The input stream with source data. outStream - The output stream that will contain the conversion output.

func (*PdfToTextClient) ConvertUrl

func (client *PdfToTextClient) ConvertUrl(url string) ([]byte, error)

Convert a PDF.

url - The address of the PDF to convert. The supported protocols are http:// and https://.

func (*PdfToTextClient) ConvertUrlToFile

func (client *PdfToTextClient) ConvertUrlToFile(url string, filePath string) error

Convert a PDF and write the result to a local file.

url - The address of the PDF to convert. The supported protocols are http:// and https://. filePath - The output file path. The string must not be empty.

func (*PdfToTextClient) ConvertUrlToStream

func (client *PdfToTextClient) ConvertUrlToStream(url string, outStream io.Writer) error

Convert a PDF and write the result to an output stream.

url - The address of the PDF to convert. The supported protocols are http:// and https://. outStream - The output stream that will contain the conversion output.

func (*PdfToTextClient) GetConsumedCreditCount

func (client *PdfToTextClient) GetConsumedCreditCount() int

Get the number of credits consumed by the last conversion.

func (*PdfToTextClient) GetDebugLogUrl

func (client *PdfToTextClient) GetDebugLogUrl() string

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

func (*PdfToTextClient) GetJobId

func (client *PdfToTextClient) GetJobId() string

Get the job id.

func (*PdfToTextClient) GetOutputSize

func (client *PdfToTextClient) GetOutputSize() int

Get the size of the output in bytes.

func (*PdfToTextClient) GetPageCount

func (client *PdfToTextClient) GetPageCount() int

Get the number of pages in the output document.

func (*PdfToTextClient) GetRemainingCreditCount

func (client *PdfToTextClient) GetRemainingCreditCount() int

Get the number of conversion credits available in your account. 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.

func (*PdfToTextClient) GetVersion

func (client *PdfToTextClient) GetVersion() string

Get the version details.

func (*PdfToTextClient) SetClientUserAgent

func (client *PdfToTextClient) SetClientUserAgent(agent string) *PdfToTextClient

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

agent - The user agent string.

func (*PdfToTextClient) SetCropArea

func (client *PdfToTextClient) SetCropArea(x int, y int, width int, height int) *PdfToTextClient

Set the crop area. It allows to extract just a part of a PDF page.

x - Set the top left X coordinate of the crop area in points. Must be a positive integer number or 0. y - Set the top left Y coordinate of the crop area in points. Must be a positive integer number or 0. width - Set the width of the crop area in points. Must be a positive integer number or 0. height - Set the height of the crop area in points. Must be a positive integer number or 0.

func (*PdfToTextClient) SetCropAreaHeight

func (client *PdfToTextClient) SetCropAreaHeight(height int) *PdfToTextClient

Set the height of the crop area in points.

height - Must be a positive integer number or 0.

func (*PdfToTextClient) SetCropAreaWidth

func (client *PdfToTextClient) SetCropAreaWidth(width int) *PdfToTextClient

Set the width of the crop area in points.

width - Must be a positive integer number or 0.

func (*PdfToTextClient) SetCropAreaX

func (client *PdfToTextClient) SetCropAreaX(x int) *PdfToTextClient

Set the top left X coordinate of the crop area in points.

x - Must be a positive integer number or 0.

func (*PdfToTextClient) SetCropAreaY

func (client *PdfToTextClient) SetCropAreaY(y int) *PdfToTextClient

Set the top left Y coordinate of the crop area in points.

y - Must be a positive integer number or 0.

func (*PdfToTextClient) SetCustomPageBreak

func (client *PdfToTextClient) SetCustomPageBreak(pageBreak string) *PdfToTextClient

Specify the custom page break.

pageBreak - String to insert between the pages.

func (*PdfToTextClient) SetDebugLog

func (client *PdfToTextClient) SetDebugLog(value bool) *PdfToTextClient

Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.

value - Set to true to enable the debug logging.

func (*PdfToTextClient) SetEol

func (client *PdfToTextClient) SetEol(eol string) *PdfToTextClient

The end-of-line convention for the text output.

eol - Allowed values are unix, dos, mac.

func (*PdfToTextClient) SetHttpProxy

func (client *PdfToTextClient) SetHttpProxy(proxy string) *PdfToTextClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*PdfToTextClient) SetHttpsProxy

func (client *PdfToTextClient) SetHttpsProxy(proxy string) *PdfToTextClient

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

proxy - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.

func (*PdfToTextClient) SetLineSpacingThreshold

func (client *PdfToTextClient) SetLineSpacingThreshold(threshold string) *PdfToTextClient

Set the maximum line spacing when the paragraph detection mode is enabled.

threshold - The value must be a positive integer percentage.

func (*PdfToTextClient) SetNoLayout

func (client *PdfToTextClient) SetNoLayout(value bool) *PdfToTextClient

Ignore the original PDF layout.

value - Set to true to ignore the layout.

func (*PdfToTextClient) SetPageBreakMode

func (client *PdfToTextClient) SetPageBreakMode(mode string) *PdfToTextClient

Specify the page break mode for the text output.

mode - Allowed values are none, default, custom.

func (*PdfToTextClient) SetParagraphMode

func (client *PdfToTextClient) SetParagraphMode(mode string) *PdfToTextClient

Specify the paragraph detection mode.

mode - Allowed values are none, bounding-box, characters.

func (*PdfToTextClient) SetPdfPassword

func (client *PdfToTextClient) SetPdfPassword(password string) *PdfToTextClient

The password to open the encrypted PDF file.

password - The input PDF password.

func (*PdfToTextClient) SetPrintPageRange

func (client *PdfToTextClient) SetPrintPageRange(pages string) *PdfToTextClient

Set the page range to print.

pages - A comma separated list of page numbers or ranges.

func (*PdfToTextClient) SetProxy

func (client *PdfToTextClient) SetProxy(host string, port int, userName string, password string) *PdfToTextClient

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

host - The proxy hostname. port - The proxy port. userName - The username. password - The password.

func (*PdfToTextClient) SetRemoveEmptyLines

func (client *PdfToTextClient) SetRemoveEmptyLines(value bool) *PdfToTextClient

Remove empty lines from the text output.

value - Set to true to remove empty lines.

func (*PdfToTextClient) SetRemoveHyphenation

func (client *PdfToTextClient) SetRemoveHyphenation(value bool) *PdfToTextClient

Remove the hyphen character from the end of lines.

value - Set to true to remove hyphens.

func (*PdfToTextClient) SetRetryCount

func (client *PdfToTextClient) SetRetryCount(count int) *PdfToTextClient

Specifies the number of automatic retries when the 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.

count - Number of retries.

func (*PdfToTextClient) SetTag

func (client *PdfToTextClient) SetTag(tag string) *PdfToTextClient

Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.

tag - A string with the custom tag.

func (*PdfToTextClient) SetUseHttp

func (client *PdfToTextClient) SetUseHttp(value bool) *PdfToTextClient

Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API. Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.

value - Set to true to use HTTP.

func (*PdfToTextClient) SetUserAgent

func (client *PdfToTextClient) SetUserAgent(agent string) *PdfToTextClient

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

agent - The user agent string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL