api2pdf
Module api2pdf
API
![](https://bcentral-packageicons.azureedge.net/images/ballerinax_api2pdf_1.5.1.png)
ballerinax/api2pdf Ballerina library
Overview
This is a generated connector for Api2Pdf REST API v2..0.0 OpenAPI specification.
This Api2Pdf REST API provides a powerful REST API for instantly generating PDF and Office documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), Email files, and images. You can generate image preview or thumbnail of a PDF, office document, or email file. The API also supports merge / concatenation of two or more PDFs, setting passwords on PDFs, and adding bookmarks to PDFs. Api2Pdf is a wrapper for popular libraries such as wkhtmltopdf, Headless Chrome, PdfSharp, and LibreOffice..
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create Api2Pdf REST API v2..0.0 account
- Obtain tokens following this guide.
Clients![](/images/permalink.svg)
api2pdf: Client![](/images/permalink.svg)
This is a generated connector from Api2Pdf OpenAPI Specification. Api2Pdf is a powerful PDF generation API with no rate limits or file size constraints. Api2Pdf runs on AWS Lambda, a serverless architecture powered by Amazon to scale to millions of requests while being up to 90% cheaper than alternatives. Supports wkhtmltopdf, Headless Chrome, LibreOffice, and PDF Merge. You can also generate barcodes with ZXING (Zebra Crossing).
Constructor![](/images/permalink.svg)
Gets invoked to initialize the connector
.
The connector initialization requires setting the API credentials.
Please create an Api2Pdf account and obtain an API key.
init (ApiKeysConfig apiKeyConfig, ConnectionConfig config, string serviceUrl)
- apiKeyConfig ApiKeysConfig - API keys for authorization
- config ConnectionConfig {} - The configurations to be used when initializing the
connector
- serviceUrl string "https://v2.api2pdf.com/" - URL of the target service
convertHtmlToPdf![](/images/permalink.svg)
function convertHtmlToPdf(ChromeHtmlToPdfRequest payload) returns ApiResponseSuccess|error
Convert raw HTML to PDF
Parameters
- payload ChromeHtmlToPdfRequest - A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
Return Type
- ApiResponseSuccess|error - A JSON object containing the url to the PDF and other meta data
convertWebUrlToPdfGet![](/images/permalink.svg)
function convertWebUrlToPdfGet(string url, string output) returns ApiResponseSuccess|error
Convert URL to PDF
Parameters
- url string - Url of the page to convert to PDF. Must start with http:// or https://.
- output string (default "json") - Specify output=json to receive a JSON output. Defaults to PDF file.
Return Type
- ApiResponseSuccess|error - A PDF file or a JSON object depending on the
output
query parameter
convertWebUrlToPdfPost![](/images/permalink.svg)
function convertWebUrlToPdfPost(ChromeUrlToPdfRequest payload) returns ApiResponseSuccess|error
Convert URL to PDF
Parameters
- payload ChromeUrlToPdfRequest - A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
Return Type
- ApiResponseSuccess|error - A JSON object containing the url to the PDF and other meta data
convertOfficeDocToPdf![](/images/permalink.svg)
function convertOfficeDocToPdf(LibreOfficeConvertRequest payload) returns ApiResponseSuccess|error
Convert office document or image to PDF
Parameters
- payload LibreOfficeConvertRequest - A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
Return Type
- ApiResponseSuccess|error - A JSON object containing the url to the PDF and other meta data
mergePdfs![](/images/permalink.svg)
function mergePdfs(MergeRequest payload) returns ApiResponseSuccess|error
Merge multiple PDFs together
Parameters
- payload MergeRequest - A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
Return Type
- ApiResponseSuccess|error - A JSON object containing the url to the PDF and other meta data
convertHtmlToPdfWithWkhtml![](/images/permalink.svg)
function convertHtmlToPdfWithWkhtml(WkHtmlToPdfHtmlToPdfRequest payload) returns ApiResponseSuccess|error
Convert raw HTML to PDF
Parameters
- payload WkHtmlToPdfHtmlToPdfRequest - A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
Return Type
- ApiResponseSuccess|error - A JSON object containing the url to the PDF and other meta data
convertWebUrlToPdfWithWkhtmlGet![](/images/permalink.svg)
function convertWebUrlToPdfWithWkhtmlGet(string url, string output) returns ApiResponseSuccess|error
Convert URL to PDF
Parameters
- url string - Url of the page to convert to PDF. Must start with http:// or https://.
- output string (default "json") - Specify output=json to receive a JSON output. Defaults to PDF file.
Return Type
- ApiResponseSuccess|error - A PDF file or a JSON object depending on the
output
query parameter
convertWebUrlToPdfWithWkhtmlPost![](/images/permalink.svg)
function convertWebUrlToPdfWithWkhtmlPost(WkHtmlToPdfUrlToPdfRequest payload) returns ApiResponseSuccess|error
Convert URL to PDF
Parameters
- payload WkHtmlToPdfUrlToPdfRequest - A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
Return Type
- ApiResponseSuccess|error - A JSON object containing the url to the PDF and other meta data
zebra![](/images/permalink.svg)
function zebra(string format, string value, boolean? showlabel, int? height, int? width) returns string|error
Generate bar codes and QR codes with ZXING.
Parameters
- format string - Most common is CODE_39 or QR_CODE
- value string - Specify the text value you want to convert
- showlabel boolean? (default ()) - Show label of text below barcode
- height int? (default ()) - Height of the barcode generated image
- width int? (default ()) - Width of the barcode generated image
Records![](/images/permalink.svg)
api2pdf: ApiKeysConfig![](/images/permalink.svg)
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- authorization string - Represents API Key
Authorization
- apikey string - Represents API Key
apikey
api2pdf: ApiResponseFailure![](/images/permalink.svg)
Fields
- reason string? - The reason for the PDF generation failure
- success boolean? - Will be false if the operation failed
api2pdf: ApiResponseSuccess![](/images/permalink.svg)
Fields
- cost decimal? - Cost of the operation (mbIn + mbOut) * $.001
- mbIn decimal? - The amount of megabytes of bandwidth used to process the pdf
- mbOut decimal? - The amount of megabytes of bandwidth generated from the resulting pdf
- pdf string? - A url to the PDF that will exist only for 24 hours
- success boolean? - Will be true if the operation suceeded
api2pdf: ChromeAdvancedOptions![](/images/permalink.svg)
Fields
- landscape string? -
- printBackground boolean? -
api2pdf: ChromeHtmlToPdfRequest![](/images/permalink.svg)
Fields
- fileName string? -
- html string -
- inlinePdf boolean? -
- options ChromeAdvancedOptions? -
api2pdf: ChromeUrlToPdfRequest![](/images/permalink.svg)
Fields
- fileName string? -
- inlinePdf boolean? -
- options ChromeAdvancedOptions? -
- url string -
api2pdf: ClientHttp1Settings![](/images/permalink.svg)
Provides settings related to HTTP/1.x protocol.
Fields
- keepAlive KeepAlive(default http:KEEPALIVE_AUTO) - Specifies whether to reuse a connection for multiple requests
- chunking Chunking(default http:CHUNKING_AUTO) - The chunking behaviour of the request
- proxy ProxyConfig? - Proxy server related options
api2pdf: ConnectionConfig![](/images/permalink.svg)
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings? - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings? - Configurations related to HTTP/2 protocol
- timeout decimal(default 60) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded
/x-forwarded
header
- poolConfig PoolConfiguration? - Configurations associated with request pooling
- cache CacheConfig? - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding
) header
- circuitBreaker CircuitBreakerConfig? - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig RetryConfig? - Configurations associated with retrying
- responseLimits ResponseLimitConfigs? - Configurations associated with inbound response size limits
- secureSocket ClientSecureSocket? - SSL/TLS-related options
- proxy ProxyConfig? - Proxy server related options
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
api2pdf: LibreOfficeConvertRequest![](/images/permalink.svg)
Fields
- fileName string? -
- inlinePdf boolean? -
- url string -
api2pdf: MergeRequest![](/images/permalink.svg)
Fields
- fileName string? -
- inlinePdf boolean? -
- urls string[] -
api2pdf: ProxyConfig![](/images/permalink.svg)
Proxy server configurations to be used with the HTTP client endpoint.
Fields
- host string(default "") - Host name of the proxy server
- port int(default 0) - Proxy server port
- userName string(default "") - Proxy server username
- password string(default "") - Proxy server password
api2pdf: WkHtmlToPdfAdvancedOptions![](/images/permalink.svg)
Fields
- orientation string? -
- pageSize string? -
api2pdf: WkHtmlToPdfHtmlToPdfRequest![](/images/permalink.svg)
Fields
- fileName string? -
- html string -
- inlinePdf boolean? -
- options WkHtmlToPdfAdvancedOptions? -
api2pdf: WkHtmlToPdfUrlToPdfRequest![](/images/permalink.svg)
Fields
- fileName string? -
- inlinePdf boolean? -
- options WkHtmlToPdfAdvancedOptions? -
- url string -
Import
import ballerinax/api2pdf;
Metadata
Released date: over 1 year ago
Version: 1.5.1
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.4.1
GraalVM compatible: Yes
Pull count
Total: 1
Current verison: 1
Weekly downloads
Keywords
Content & Files/Documents
Cost/Freemium
Contributors
Dependencies