openapi: 3.0.0
servers:
  - description: Api2Pdf.com API
    url: https://v2018.api2pdf.com
info:
  contact:
    email: support@api2pdf.com
    name: Support
    x-twitter: api2pdf_status
  description: |
    
    # Introduction
    [Api2Pdf](https://www.api2pdf.com) 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).
    # SDKs & Client Libraries
    We've made a number of open source libraries available for the API
    - Python: [https://github.com/api2pdf/api2pdf.python](https://github.com/api2pdf/api2pdf.python)
    - .NET: [https://github.com/api2pdf/api2pdf.dotnet](https://github.com/api2pdf/api2pdf.dotnet)
    - Nodejs: [https://github.com/api2pdf/api2pdf.node](https://github.com/api2pdf/api2pdf.node)
    - PHP: [https://github.com/Api2Pdf/api2pdf.php](https://github.com/Api2Pdf/api2pdf.php)
    - Ruby: (Coming soon)
    # Authorization
    Create an account at [portal.api2pdf.com](https://portal.api2pdf.com/register) to get an API key.

    **Authorize your API calls**
    - GET requests, include apikey=YOUR-API-KEY as a query string parameter
    - POST requests, add **Authorization** to your header.
    ``` Authorization: YOUR-API-KEY ```

    # Quickstart
    If you are looking for just a quick call to grab PDFs of a URL, you can do a GET request like:
    ``` https://v2018.api2pdf.com/chrome/url?url={UrlToConvert}&apikey={YourApiKey} ```

    For more advanced usage and settings, see the API specification below.
  license:
    name: Creative Commons
    url: https://creativecommons.org/licenses/by/4.0/legalcode
  title: Api2Pdf - PDF Generation, Powered by AWS Lambda
  version: 1.0.0
  x-apisguru-categories:
    - developer_tools
  x-logo:
    url: https://twitter.com/api2pdf_status/profile_image?size=original
  x-origin:
    - converter:
        url: https://github.com/lucybot/api-spec-converter
        version: 2.7.18
      format: openapi
      url: https://app.swaggerhub.com/apiproxy/schema/file/api2pdf/api2pdf/1.0.0/swagger.json
      version: "3.0"
  x-providerName: api2pdf.com
externalDocs:
  description: Find out more about Api2Pdf
  url: https://www.api2pdf.com
security:
  - HeaderApiKey: []
paths:
  /chrome/html:
    post:
      description: |-
        Convert HTML to a PDF using Headless Chrome on AWS Lambda.
        ### Authorize via Header of Request
        **Authorization: YOUR-API-KEY**
      operationId: chromeFromHtmlPost
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChromeHtmlToPdfRequest"
        description: |-
          A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
          - `html` *(string, required)* - raw HTML to convert to PDF
          - `inlinePdf` *(boolean, optional)* - Open the PDF in a browser window. Default to false.
          - `fileName` *(string, optional)* - Specify a file name for the output PDF. Random name if not specified.
          - `options` *(object, optional)* - Include advanced Headless Chrome options like margins, headers, and footers. [See full list of advanced options here](https://www.api2pdf.com/documentation/advanced-options-headless-chrome/).
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
          description: A JSON object containing the url to the PDF and other meta data
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      summary: Convert raw HTML to PDF
      tags:
        - Headless Chrome
  /chrome/url:
    get:
      description: |-
        Convert a URL or Web Page to PDF using Headless Chrome on AWS Lambda. This GET request is for convenience and does not support advanced options. Use the POST request for more flexibility.
        ### Authorize via Query String Parameter
        **apikey=YOUR-API-KEY**
        ### Example
        ``` https://v2018.api2pdf.com/chrome/url?url={UrlToConvert}&apikey={YourApiKey} ``` 
      operationId: chromeFromUrlGET
      parameters:
        - description: Url of the page to convert to PDF. Must start with http:// or https://.
          in: query
          name: url
          required: true
          schema:
            type: string
        - description: Specify output=json to receive a JSON output. Defaults to PDF file.
          in: query
          name: output
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
            application/pdf:
              schema:
                format: binary
                type: string
          description: A PDF file or a JSON object depending on the `output` query parameter
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      security:
        - QueryApiKey: []
      summary: Convert URL to PDF
      tags:
        - Headless Chrome
    post:
      description: |-
        Convert a URL or Web Page to PDF using Headless Chrome on AWS Lambda..
        ### Authorize via Header of Request
        **Authorization: YOUR-API-KEY**
      operationId: chromeFromUrlPost
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChromeUrlToPdfRequest"
        description: |-
          A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
          - `url` *(string, required)* - Url to the web page to convert to PDF
          - `inlinePdf` *(boolean, optional)* - Open the PDF in a browser window. Default to false.
          - `fileName` *(string, optional)* - Specify a file name for the output PDF. Random name if not specified.
          - `options` *(object, optional)* - Include advanced Headless Chrome options like margins, headers, and footers. [See full list of advanced options here](https://www.api2pdf.com/documentation/advanced-options-headless-chrome/).
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
          description: A JSON object containing the url to the PDF and other meta data
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      summary: Convert URL to PDF
      tags:
        - Headless Chrome
  /libreoffice/convert:
    post:
      description: |-
        Convert an office document (Word, Excel, Powerpoint) or an image (jpg, gif, png) to a PDF using LibreOffice on AWS Lambda.
        ### Authorize via Header of Request
        **Authorization: YOUR-API-KEY**
      operationId: libreConvertPost
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LibreOfficeConvertRequest"
        description: |-
          A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
          - `url` *(string, required)* - A direct URL to the file. Api2Pdf will consume the file at that URL and then convert it.
          - `inlinePdf` *(boolean, optional)* - Open the PDF in a browser window. Default to false.
          - `fileName` *(string, optional)* - Specify a file name for the output PDF. Random name if not specified. 
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
          description: A JSON object containing the url to the PDF and other meta data
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      summary: Convert office document or image to PDF
      tags:
        - LibreOffice
  /merge:
    post:
      description: |-
        Merge two or more PDFs together on AWS Lambda.
        ### Authorize via Header of Request
        **Authorization: YOUR-API-KEY**
      operationId: mergePost
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MergeRequest"
        description: |-
          A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
          - `urls` *(array of urls, required)* - A JSON array of direct URLs to PDFs. Api2Pdf will consume the PDF files in the list and then merge them all together..
          - `inlinePdf` *(boolean, optional)* - Open the PDF in a browser window. Default to false.
          - `fileName` *(string, optional)* - Specify a file name for the output PDF. Random name if not specified. 
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
          description: A JSON object containing the url to the PDF and other meta data
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      summary: Merge multiple PDFs together
      tags:
        - Merge / Combine Pdfs
  /wkhtmltopdf/html:
    post:
      description: |-
        Convert HTML to a PDF using WkHtmlToPdf on AWS Lambda.
        ### Authorize via Header of Request
        **Authorization: YOUR-API-KEY**
      operationId: wkhtmltopdfFromHtmlPost
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WkHtmlToPdfHtmlToPdfRequest"
        description: |-
          A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
          - `html` *(string, required)* - raw HTML to convert to PDF
          - `inlinePdf` *(boolean, optional)* - Open the PDF in a browser window. Default to false.
          - `fileName` *(string, optional)* - Specify a file name for the output PDF. Random name if not specified.
          - `options` *(object, optional)* - Include advanced WkHtmlToPdf options like margins, headers, and footers. [See full list of advanced options here](https://www.api2pdf.com/documentation/advanced-options-wkhtmltopdf/).
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
          description: A JSON object containing the url to the PDF and other meta data
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      summary: Convert raw HTML to PDF
      tags:
        - wkhtmltopdf
  /wkhtmltopdf/url:
    get:
      description: |-
        Convert a URL or Web Page to PDF using WkHtmlToPdf on AWS Lambda. This GET request is for convenience and does not support advanced options. Use the POST request for more flexibility.
        ### Authorize via Query String Parameter
        **apikey=YOUR-API-KEY**
        ### Example
        ``` https://v2018.api2pdf.com/wkhtmltopdf/url?url={UrlToConvert}&apikey={YourApiKey} ``` 
      operationId: wkhtmltopdfFromUrlGET
      parameters:
        - description: Url of the page to convert to PDF. Must start with http:// or https://.
          in: query
          name: url
          required: true
          schema:
            type: string
        - description: Specify output=json to receive a JSON output. Defaults to PDF file.
          in: query
          name: output
          schema:
            type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
            application/pdf:
              schema:
                format: binary
                type: string
          description: A PDF file or a JSON object depending on the `output` query parameter
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      security:
        - QueryApiKey: []
      summary: Convert URL to PDF
      tags:
        - wkhtmltopdf
    post:
      description: |-
        Convert a URL or Web Page to PDF using WkHtmlToPdf on AWS Lambda..
        ### Authorize via Header of Request
        **Authorization: YOUR-API-KEY**
      operationId: wkhtmltopdfFromUrlPost
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WkHtmlToPdfUrlToPdfRequest"
        description: |-
          A JSON object as a payload is required within the body of the request. The following attributes of the JSON object are detailed below:
          - `url` *(string, required)* - Url to the web page to convert to PDF
          - `inlinePdf` *(boolean, optional)* - Open the PDF in a browser window. Default to false.
          - `fileName` *(string, optional)* - Specify a file name for the output PDF. Random name if not specified.
          - `options` *(object, optional)* - Include advanced WkHtmlToPdf options like margins, headers, and footers. [See full list of advanced options here](https://www.api2pdf.com/documentation/advanced-options-wkhtmltopdf/).
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseSuccess"
          description: A JSON object containing the url to the PDF and other meta data
        "401":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiResponseFailure"
          description: Failed to generate PDF
      summary: Convert URL to PDF
      tags:
        - wkhtmltopdf
  /zebra:
    get:
      description: |-
        See full list of options and documentation [here](https://www.api2pdf.com/documentation/advanced-options-zxing-zebra-crossing-barcodes/)
        ### Authorize via Query String Parameter
        **apikey=YOUR-API-KEY**
        ### Example
        ``` https://v2018.api2pdf.com/zebra?format={format}&apikey={YourApiKey}&value={YourText} ``` 
      operationId: zebraGET
      parameters:
        - description: Most common is CODE_39 or QR_CODE
          in: query
          name: format
          required: true
          schema:
            type: string
        - description: Specify the text value you want to convert
          in: query
          name: value
          required: true
          schema:
            type: string
        - description: Show label of text below barcode
          in: query
          name: showlabel
          schema:
            type: boolean
        - description: Height of the barcode generated image
          in: query
          name: height
          schema:
            type: integer
        - description: Width of the barcode generated image
          in: query
          name: width
          schema:
            type: integer
      responses:
        "200":
          content:
            image/png:
              schema:
                format: binary
                type: string
          description: An image of the generated barcode or QR code
      security:
        - QueryApiKey: []
      summary: Generate bar codes and QR codes with ZXING.
      tags:
        - ZXING (Zebra Crossing) Bar Codes
components:
  schemas:
    ApiResponseFailure:
      properties:
        reason:
          description: The reason for the PDF generation failure
          example: Source website could not be found
          type: string
        success:
          description: Will be false if the operation failed
          example: false
          type: boolean
      type: object
    ApiResponseSuccess:
      properties:
        cost:
          description: Cost of the operation (mbIn + mbOut) * $.001
          example: 0.0007979
          type: number
        mbIn:
          description: The amount of megabytes of bandwidth used to process the pdf
          example: 0.06463
          type: number
        mbOut:
          description: The amount of megabytes of bandwidth generated from the resulting pdf
          example: 0.73327
          type: number
        pdf:
          description: A url to the PDF that will exist only for 24 hours
          example: https://link-to-your-pdf
          type: string
        success:
          description: Will be true if the operation suceeded
          example: true
          type: boolean
      type: object
    ChromeAdvancedOptions:
      properties:
        landscape:
          example: "true"
          type: string
        printBackground:
          example: false
          type: boolean
      type: object
    ChromeHtmlToPdfRequest:
      properties:
        fileName:
          example: test.pdf
          type: string
        html:
          example: <p>Hello World</p>
          format: html
          type: string
        inlinePdf:
          example: true
          type: boolean
        options:
          $ref: "#/components/schemas/ChromeAdvancedOptions"
      required:
        - html
      type: object
    ChromeUrlToPdfRequest:
      properties:
        fileName:
          example: test.pdf
          type: string
        inlinePdf:
          example: true
          type: boolean
        options:
          $ref: "#/components/schemas/ChromeAdvancedOptions"
        url:
          example: https://www.github.com
          format: url
          type: string
      required:
        - url
      type: object
    LibreOfficeConvertRequest:
      properties:
        fileName:
          example: test.pdf
          type: string
        inlinePdf:
          example: true
          type: boolean
        url:
          example: https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx
          format: url
          type: string
      required:
        - url
      type: object
    MergeRequest:
      properties:
        fileName:
          example: test.pdf
          type: string
        inlinePdf:
          example: true
          type: boolean
        urls:
          example:
            - link-to-pdf1
            - link-to-pdf2
            - link-to-pdf3
          format: list of urls to pdfs
          items:
            type: string
          type: array
      required:
        - urls
      type: object
    WkHtmlToPdfAdvancedOptions:
      properties:
        orientation:
          example: landscape
          type: string
        pageSize:
          example: A4
          type: string
      type: object
    WkHtmlToPdfHtmlToPdfRequest:
      properties:
        fileName:
          example: test.pdf
          type: string
        html:
          example: <p>Hello World</p>
          format: html
          type: string
        inlinePdf:
          example: true
          type: boolean
        options:
          $ref: "#/components/schemas/WkHtmlToPdfAdvancedOptions"
      required:
        - html
      type: object
    WkHtmlToPdfUrlToPdfRequest:
      properties:
        fileName:
          example: test.pdf
          type: string
        inlinePdf:
          example: true
          type: boolean
        options:
          $ref: "#/components/schemas/WkHtmlToPdfAdvancedOptions"
        url:
          example: https://www.github.com
          format: url
          type: string
      required:
        - url
      type: object
  securitySchemes:
    HeaderApiKey:
      in: header
      name: Authorization
      type: apiKey
    QueryApiKey:
      in: query
      name: apikey
      type: apiKey
