api2pdf
Module api2pdf
API
![](https://bcentral-dev-packageicons.azureedge.net/images/ballerinax_api2pdf_1.4.0.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, ClientConfiguration clientConfig, string serviceUrl)
- apiKeyConfig ApiKeysConfig - API keys for authorization
- clientConfig ClientConfiguration {} - 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: LibreOfficeConvertRequest![](/images/permalink.svg)
Fields
- fileName string? -
- inlinePdf boolean? -
- url string -
api2pdf: MergeRequest![](/images/permalink.svg)
Fields
- fileName string? -
- inlinePdf boolean? -
- urls string[] -
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.4.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.2.1
GraalVM compatible: Yes
Pull count
Total: 2
Current verison: 0
Weekly downloads
Keywords
Content & Files/Documents
Cost/Freemium
Contributors
Dependencies