Operations

POST/v1/operations/optimize

Compress and optimize a PDF

Compress and optimize PDF and PDF/A files with the Pdftools API.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for optimization operation.

  • Name
    options.profile
    Type
    string
    Type
    Optional
    Description

    Optimization profile to be used

    Type
    Accepted values: web, archive, print, minimalFileSize
    Type
    Default value: minimalFileSize

Optimization Profiles

An optimization profile contains predetermined configuration settings that help you optimize a PDF document for a specific use.

Web: Compress the file without affecting viewing quality on digital devices

  • Removes redundant and unnecessary data for electronic document exchange
  • Downsamples, clips, and intelligently compresses images
  • Merges and subsets fonts
  • Linearizes the output
  • Converts colors to RGB

Archive: Prepare a document for archiving in PDF/A format

  • Removes redundant and unnecessary data for archiving
  • Intelligently compresses images
  • Merges and subsets fonts

Print: Compress the file without affecting print quality

  • Removes redundant and unnecessary data for printing
  • Downsamples, clips, and intelligently compresses images
  • Merges and subsets fonts
  • Converts colors to CMYK

Minimal file size: Remove redundant data and reduce image resolution to achieve a minimal viable file size

  • Downsamples images
  • Converts Type1 fonts to Type1C
  • Removes metadata and output intents

Request

POST
/v1/operations/optimize
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/optimize' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "options": {
        "profile": "archive"
    },
    "input": {
        "fileId": "<FILE_ID>"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "optimize",
  "operationStatus": "inProgress"
}


POST/v1/operations/convert/image-to-pdf

Convert image to PDF

Convert JPEG, PNG, and TIFF image formats into PDFs. Choose the output PDF's page size and determine the margins of the page in the output document. During the conversion process, the images are resized automatically. You can also specify how to shrink the image size to fit a portrait or landscape layout.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for optimization operation.

  • Name
    options.pageSize
    Type
    string
    Type
    Optional
    Description

    The desired target page size

    Type
    Accepted values: a4, letter
    Type
    Default value: a4
  • Name
    options.pageMargin
    Type
    object
    Type
    Optional
    Description

    Object that contains options for page margins.

  • Name
    options.pageMargin.margin
    Type
    float
    Type
    Required
    Description

    The desired page margin. The same value is applied to the left, top, right, and bottom margins of the page.

  • Name
    options.pageMargin.unit
    Type
    string
    Type
    Required
    Description

    The margin measurement unit. Accepted values: cm, in

  • Name
    options.strategy
    Type
    string
    Type
    Optional
    Description

    Conversion strategy

    Type
    Accepted values: Auto, ShrinkToPage, ShrinkToPortrait
    Type
    Default value: Auto

Request

POST
/v1/operations/convert/image-to-pdf
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/image-to-pdf' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "pageSize": "a4",
        "pageMargin": {
            "margin": 2.54,
            "unit": "cm"
        },
        "strategy": "auto"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "convertImage",
  "operationStatus": "inProgress"
}


POST/v1/operations/archive/pdfa

Convert PDF to PDF/A

Convert PDFs to PDF/A format for archiving. The Pdftools API supports the following PDF/A versions:

PDF/A-2b Basic conformance with archival standards but revised for later versions of the PDF format.

PDF/A-3b Matches PDF/A-2b, except that it is possible to embed any kind of file in the PDF. The embedded file does not need to be PDF/A compliant. For example, with PDF/A-3 a user can save an XML, CSV, CAD, spreadsheet, or other type of file in the PDF and comply with the PDF/A-3b standard.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for optimization operation.

  • Name
    options.conformance
    Type
    string
    Type
    Required
    Description

    The pdf-a desired conformance.

    Type
    Accepted values: pdf_a2_b, pdf_a3_b

Request

POST
/v1/operations/archive/pdfa
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/archive/pdfa' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "conformance"": "pdf_a2_b"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "archivePdfA",
  "operationStatus": "inProgress"
}
POST/v1/operations/convert/pdf-to-jpeg

Convert PDF to JPEG

Convert PDFs to JPEG files with Pdftools API for use in web and desktop viewing applications or as thumbnails. If you don't pass any options, the default image output is RGB for ColorSpace and 85 for JpegQuality. When you convert a multi-page PDF file, the output is a zip file that contains one image file for each page of the original PDF file.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for optimization operation.

  • Name
    options.colorSpace
    Type
    string
    Type
    Required
    Description

    The color space used in JPEG images

    Type
    Accepted values: rgb, gray, cmyk
  • Name
    options.jpegQuality
    Type
    int
    Type
    Required
    Description

    Jpeg compression quality, valid values are between 0 and 100.

  • Name
    options.maxSizeInPixels
    Type
    object
    Type
    Optional
    Description

    When specified, it sets a maximum resolution in pixels for the output image, and it always keeps the aspect ratio.

  • Name
    options.maxSizeInPixels.width
    Type
    int
    Type
    Required
    Description

    The maximum width specified. Accepted values: cm, in

  • Name
    options.maxSizeInPixels.height
    Type
    int
    Type
    Required
    Description

    The maximum height specified.

Request

POST
/v1/operations/convert/pdf-to-jpeg
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/pdf-to-jpeg' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "colorSpace"": "rgb",
        "jpegQuality": 80
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "convertPdfToJpeg",
  "operationStatus": "inProgress"
}


POST/v1/operations/convert/pdf-to-png

Convert PDF to PNG

Convert PDFs to PNG files with Pdftools API for use in web and desktop viewing applications or as thumbnails. If no options are passed, the default image output is RGB for ColorSpace and White for Background. When you convert a multi-page PDF file, the output is a zip file that contains one image file for each page of the original PDF file.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for optimization operation.

  • Name
    options.colorSpace
    Type
    string
    Type
    Optional
    Description

    The color space used in PNG images.

    Type
    Accepted values: rgb, gray
    Type
    Default value: rgb
  • Name
    options.transparentBackground
    Type
    bool
    Type
    Optional
    Description

    When true, the input PDF content is rendered into an image with an alpha channel and no background. If false, the input PDF content is generated on a white background. Default value: false

    Type
    Default value: false
  • Name
    options.maxSizeInPixels
    Type
    object
    Type
    Optional
    Description

    When specified, it sets a maximum resolution in pixels for the output image, and it always keeps the aspect ratio.

  • Name
    options.maxSizeInPixels.width
    Type
    int
    Type
    Required
    Description

    The maximum width specified. Accepted values: cm, in

  • Name
    options.maxSizeInPixels.height
    Type
    int
    Type
    Required
    Description

    The maximum height specified.

Request

POST
/v1/operations/convert/pdf-to-png
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/pdf-to-png' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "colorSpace": "rgb",
        "transparentBackground": true
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "convertPdfToPng",
  "operationStatus": "inProgress"
}


POST/v1/operations/convert/pdf-to-tiff

Convert PDF to TIFF

Convert PDFs to TIFF images for archiving. This conversion is suitable for archiving PDFs as rasterized images. The color space of each image corresponds to the color space of the PDF page.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

Request

POST
/v1/operations/convert/pdf-to-tiff
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/pdf-to-tiff' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "convertPdfToTiff",
  "operationStatus": "inProgress"
}
POST/v1/operations/convert/pdf-to-tiff-fax

Convert PDF to TIFF Fax

Convert PDFs into TIFF-F conforming rasterized images for facsimile transmission. The output format is a multi-page TIFF file that contains all rasterized PDF pages.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

Request

POST
/v1/operations/convert/pdf-to-tiff-fax
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/pdf-to-tiff-fax' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "convertPdfToTiffFax",
  "operationStatus": "inProgress"
}
POST/v1/operations/convert/doc-to-pdf

Convert Doc to PDF

Converts Word Processing Documents to pdf. Supported file formats:

  • Microsoft Word (.doc, .docx)
  • OpenDocument Text (.odt)
  • Rich Text Format (.rtf)
  • WordPerfect (.wpd)
  • Plain Text (.txt)

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

Request

POST
/v1/operations/convert/doc-to-pdf
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/doc-to-pdf' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "docToPdf",
  "operationStatus": "inProgress"
}
POST/v1/operations/convert/presentation-to-pdf

Convert Presentation to PDF

Converts Presentation Documents to pdf. Supported file formats:

  • Microsoft PowerPoint (.ppt, .pptx)
  • OpenDocument Presentation (.odp)

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

Request

POST
/v1/operations/convert/presentation-to-pdf
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/presentation-to-pdf' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "presentationToPdf",
  "operationStatus": "inProgress"
}
POST/v1/operations/convert/spreadsheet-to-pdf

Convert Spreadsheet to PDF

Converts Spreadsheet Documents to pdf. Supported file formats:

  • Microsoft Excel (.xls, .xlsx)
  • OpenDocument Spreadsheet (.ods)
  • Comma-separated values (.csv)

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

Request

POST
/v1/operations/convert/spreadsheet-to-pdf
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/convert/spreadsheet-to-pdf' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "spreadsheetToPdf",
  "operationStatus": "inProgress"
}
POST/v1/operations/encrypt

Encrypt a PDF

Add a password to PDFs in order to encrypt them.

Request body

  • Name
    input
    Type
    object
    Type
    Optional
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Optional
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for the operation.

  • Name
    options.password
    Type
    string
    Type
    Optional
    Description

    Encryption password.

Request

POST
/v1/operations/encrypt
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/encrypt' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "password": "mypassword"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "encryptPdf",
  "operationStatus": "inProgress"
}
POST/v1/operations/decrypt

Decrypt a PDF

Remvove the password from PDFs in order to decrypt them.

Request body

  • Name
    input
    Type
    object
    Type
    Optional
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Optional
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for the operation.

  • Name
    options.password
    Type
    string
    Type
    Optional
    Description

    Decryption password.

Request

POST
/v1/operations/decrypt
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/decrypt' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "password": "mypassword"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "decryptPdf",
  "operationStatus": "inProgress"
}
POST/v1/operations/stamp/text

Stamp text on a PDF

Add text stamps on PDFs through the Pdftools API. A text stamp annotation displays text intended to look as if it was stamped on the page with a rubber stamp. You can determine the text of the stamp, the appearance (font family, style, and color), and the position on the page. The position of the stamp is calculated by passing the margin key. The margin specifies the location using direction indicators and a unit of measurement, either metric (cm) or inches (in). The fonts used for fontFamily key are LiberationSans (value sans) and LiberationSerif (value serif).

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    URL of the file.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    URL of the file.

  • Name
    options
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp text operation.

  • Name
    options.text
    Type
    string
    Type
    Required
    Description

    The text of the stamp.

  • Name
    options.textStyle
    Type
    object
    Type
    Optional
    Description

    Object that contains options for text styling.

  • Name
    options.textStyle.textColor
    Type
    string
    Type
    Optional
    Description

    The text color (Web color name or hex #XXXXXX).

    Type
    Default value: black
  • Name
    options.textStyle.fontFamily
    Type
    string
    Type
    Optional
    Description

    The text font family, either LiberationSans or LiberationSerif.

    Type
    Accepted values: sans, serif
    Type
    Default value: sans
  • Name
    options.textStyle.isBold
    Type
    bool
    Type
    Optional
    Description

    Specifies whether the text is bold.

    Type
    Default value: false
  • Name
    options.textStyle.isItalic
    Type
    bool
    Type
    Optional
    Description

    Determines whether the text is italicized.

    Type
    Default value: false
  • Name
    options.textStyle.fontSize
    Type
    double
    Type
    Optional
    Description

    The font size in pt.

    Type
    Default value: 10
  • Name
    options.margin
    Type
    object
    Type
    Optional
    Description

    Object that contains options for page margins.

  • Name
    options.margin.left
    Type
    float
    Type
    Optional
    Description

    The distance from the left border of the page.

    Type
    Default value: 0
  • Name
    options.margin.top
    Type
    float
    Type
    Optional
    Description

    The distance from the top border of the page.

    Type
    Default value: 0
  • Name
    options.margin.right
    Type
    float
    Type
    Optional
    Description

    The distance from the right border of the page.

    Type
    Default value: 0
  • Name
    options.margin.bottom
    Type
    float
    Type
    Optional
    Description

    The distance from the bottom border of the page.

    Type
    Default value: 0
  • Name
    options.margin.unit
    Type
    string
    Type
    Optional
    Description

    The margin measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm

Request

POST
/v1/operations/stamp/text
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/stamp/text' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "margin": {
        "top": 1.0,
        "right": 1.0,
        "unit": "in"
        },
        "text": "pdf-tools"
        "textStyle": {
            "textColor": "black",
            "fontFamily": "serif",
            "isBold": false,
            "isItalic": false,
            "fontSize": 12
        }
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "stampText",
  "operationStatus": "inProgress"
}


POST/v1/operations/stamp/watermark

Stamp watermark on a PDF

Add watermarks on PDFs using the Pdftools API. A watermark annotation lets you add text as a watermark to all pages of the PDF. Determine the text to be displayed as a watermark, the appearance (font family, style, and color), and the position on the page. Watermark text has an opacity of 0.5 and an angle of 45°.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    URL of the file.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    URL of the file.

  • Name
    options
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp text operation.

  • Name
    options.text
    Type
    string
    Type
    Required
    Description

    The text of the stamp.

  • Name
    options.textStyle
    Type
    object
    Type
    Optional
    Description

    Object that contains options for text styling.

  • Name
    options.textStyle.textColor
    Type
    string
    Type
    Optional
    Description

    The text color (Web color name or hex #XXXXXX).

    Type
    Default value: black
  • Name
    options.textStyle.fontFamily
    Type
    string
    Type
    Optional
    Description

    The text font family, either LiberationSans or LiberationSerif.

    Type
    Accepted values: sans, serif
    Type
    Default value: sans
  • Name
    options.textStyle.isBold
    Type
    bool
    Type
    Optional
    Description

    Specifies whether the text is bold.

    Type
    Default value: false
  • Name
    options.textStyle.isItalic
    Type
    bool
    Type
    Optional
    Description

    Determines whether the text is italicized.

    Type
    Default value: false
  • Name
    options.textStyle.fontSize
    Type
    double
    Type
    Optional
    Description

    The font size in pt.

    Type
    Default value: 10
  • Name
    options.margin
    Type
    object
    Type
    Optional
    Description

    Object that contains options for page margins.

  • Name
    options.margin.left
    Type
    float
    Type
    Optional
    Description

    The distance from the left border of the page.

    Type
    Default value: 0
  • Name
    options.margin.top
    Type
    float
    Type
    Optional
    Description

    The distance from the top border of the page.

    Type
    Default value: 0
  • Name
    options.margin.right
    Type
    float
    Type
    Optional
    Description

    The distance from the right border of the page.

    Type
    Default value: 0
  • Name
    options.margin.bottom
    Type
    float
    Type
    Optional
    Description

    The distance from the bottom border of the page.

    Type
    Default value: 0
  • Name
    options.margin.unit
    Type
    string
    Type
    Optional
    Description

    The margin measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm

Request

POST
/v1/operations/stamp/watermark
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/stamp/watermark' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "margin": {
        "top": 1.0,
        "right": 1.0,
        "unit": "in"
        },
        "text": "pdf-tools"
        "textStyle": {
            "textColor": "#000000",
            "fontFamily": "sans",
            "isBold": false,
            "isItalic": false,
            "fontSize": 12
        }
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "stampWatermark",
  "operationStatus": "inProgress"
}


POST/v1/operations/stamp/barcode

Stamp a barcode on a PDF

Add a barcode stamp on PDFs. A barcode is a one-dimensional code representation consisting of black and white lines varied in width, spacing, and size. A barcode annotation places a previously generated barcode on the page. You can determine the position of the barcode on the page and its relative size by passing the barcode as a URL.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    URL of the file.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    URL of the file.

  • Name
    options
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp barcode operation.

  • Name
    options.type
    Type
    string
    Type
    Required
    Description

    The barcode type of the stamp. Accepted values: ean13, code128

  • Name
    options.value
    Type
    string
    Type
    Required
    Description

    The value of the barcode.

  • Name
    options.stampSize
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp size.

  • Name
    options.stampSize.width
    Type
    float
    Type
    Required
    Description

    The width of the barcode.

  • Name
    options.stampSize.height
    Type
    float
    Type
    Required
    Description

    The height of the barcode.

  • Name
    options.stampSize.unit
    Type
    string
    Type
    Optional
    Description

    The width and height measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm
  • Name
    options.margin
    Type
    object
    Type
    Optional
    Description

    Object that contains options for page margins.

  • Name
    options.margin.left
    Type
    float
    Type
    Optional
    Description

    The distance from the left border of the page.

    Type
    Default value: 0
  • Name
    options.margin.top
    Type
    float
    Type
    Optional
    Description

    The distance from the top border of the page.

    Type
    Default value: 0
  • Name
    options.margin.right
    Type
    float
    Type
    Optional
    Description

    The distance from the right border of the page.

    Type
    Default value: 0
  • Name
    options.margin.bottom
    Type
    float
    Type
    Optional
    Description

    The distance from the bottom border of the page.

    Type
    Default value: 0
  • Name
    options.margin.unit
    Type
    string
    Type
    Optional
    Description

    The margin measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm

Request

POST
/v1/operations/stamp/barcode
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/stamp/barcode' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "margin": {
        "left": 2,
        "bottom": 2,
        "unit": "cm"
        }
        "type": "code128",
        "value": ""12345678"",
        "stampSize": {
            "width": 2,
            "height": 0.1,
            "unit": "cm"
        }
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "stampBarcode",
  "operationStatus": "inProgress"
}


POST/v1/operations/stamp/qr

Stamp a QR code on a PDF

Add QR codes on PDFs. A QR code is a two-dimensional code with black and white dots arranged in a square pattern. A QR code annotation places the previously generated QR code on the page. You can determine the position of the QR code on the page and its relative size by passing the QR code itself as a URL.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    URL of the file.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    URL of the file.

  • Name
    options
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp QR operation.

  • Name
    options.value
    Type
    string
    Type
    Required
    Description

    The value of the barcode.

  • Name
    options.stampSize
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp size.

  • Name
    options.stampSize.side
    Type
    float
    Type
    Required
    Description

    The side length of the code stamp.

  • Name
    options.stampSize.unit
    Type
    string
    Type
    Optional
    Description

    The width and height measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm
  • Name
    options.margin
    Type
    object
    Type
    Optional
    Description

    Object that contains options for page margins.

  • Name
    options.margin.left
    Type
    float
    Type
    Optional
    Description

    The distance from the left border of the page.

    Type
    Default value: 0
  • Name
    options.margin.top
    Type
    float
    Type
    Optional
    Description

    The distance from the top border of the page.

    Type
    Default value: 0
  • Name
    options.margin.right
    Type
    float
    Type
    Optional
    Description

    The distance from the right border of the page.

    Type
    Default value: 0
  • Name
    options.margin.bottom
    Type
    float
    Type
    Optional
    Description

    The distance from the bottom border of the page.

    Type
    Default value: 0
  • Name
    options.margin.unit
    Type
    string
    Type
    Optional
    Description

    The margin measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm

Request

POST
/v1/operations/stamp/qr
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/stamp/qr' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "margin": {
        "left": 2,
        "bottom": 2,
        "unit": "cm"
        }
        "value": "12345678",
        "stampSize": {
            "side": 2,
            "unit": "cm"
        }
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "stampQR",
  "operationStatus": "inProgress"
}


POST/v1/operations/stamp/data-matrix

Stamp data matrix on a PDF

Add a data matrix on PDFs. A data matrix is a two-dimensional code consisting of black and white dots arranged in a square pattern, similar to a QR code. A data matrix annotation places a previously generated data matrix on the page. You can determine the position of the data matrix on the page and its relative size by passing the data matrix itself as a URL.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    URL of the file.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    URL of the file.

  • Name
    options
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp data matrix operation.

  • Name
    options.value
    Type
    string
    Type
    Required
    Description

    The value of the barcode.

  • Name
    options.stampSize
    Type
    object
    Type
    Required
    Description

    Object that contains options for stamp size.

  • Name
    options.stampSize.side
    Type
    float
    Type
    Required
    Description

    The side length of the code stamp.

  • Name
    options.stampSize.unit
    Type
    string
    Type
    Optional
    Description

    The width and height measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm
  • Name
    options.margin
    Type
    object
    Type
    Optional
    Description

    Object that contains options for page margins.

  • Name
    options.margin.left
    Type
    float
    Type
    Optional
    Description

    The distance from the left border of the page.

    Type
    Default value: 0
  • Name
    options.margin.top
    Type
    float
    Type
    Optional
    Description

    The distance from the top border of the page.

    Type
    Default value: 0
  • Name
    options.margin.right
    Type
    float
    Type
    Optional
    Description

    The distance from the right border of the page.

    Type
    Default value: 0
  • Name
    options.margin.bottom
    Type
    float
    Type
    Optional
    Description

    The distance from the bottom border of the page.

    Type
    Default value: 0
  • Name
    options.margin.unit
    Type
    string
    Type
    Optional
    Description

    The margin measurement unit.

    Type
    Accepted values: cm, in
    Type
    Default value: cm

Request

POST
/v1/operations/stamp/data-matrix
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/stamp/data-matrix' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "margin": {
        "left": 2,
        "bottom": 2,
        "unit": "cm"
        }
        "value": "12345678",
        "stampSize": {
            "side": 2,
            "unit": "cm"
        }
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "stampDataMatrix",
  "operationStatus": "inProgress"
}


POST/v1/operations/workflows/powerarchive

Power archive

This workflow is tailored to document archiving, meaning that the power archive workflow compresses your documents optimally for the standards of PDF/A technical specifications in a single API call.

Choose one of the two provided PDF/A versions for archiving. The Pdftools API supports the following PDF/A versions:

PDF/A-2b
Basic conformance with archival standards but revised for later versions of the PDF format. The key is parsed under conformance with the value pdf_a2_b.
PDF/A-3b
Matches PDF/A-2b, except that it is possible to embed any kind of file in the PDF. The embedded file does not need to be PDF/A compliant. For example, with PDF/A-3 a user can save an XML, CSV, CAD, spreadsheet, or other type of file in the PDF and comply with the PDF/A-3b standard. The key is parsed under conformance with the value pdf_a3_b.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    URL of the file.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    URL of the file.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    Object that contains options for the operation.

  • Name
    options.conformance
    Type
    string
    Type
    Required
    Description

    The pdf-a desired conformance.

    Type
    Accepted values: pdf_a2_b, pdf_a3_b

Request

POST
/v1/workflows/powerarchive
curl -L -X POST 'https://api.pdf-tools.com/v1-beta/operations/workflows/powerarchive' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "conformance"": "pdf_a2_b"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "powerArchive",
  "operationStatus": "inProgress"
}
POST/v1/operations/validate

PDF validation

Check whether a PDF conforms to a specific PDF standard, specification, and conformance level such as PDF/A-1 or PDF/A-2b.

Request body

  • Name
    input
    Type
    object
    Type
    Required
    Description

    Input object that contains file ID.

  • Name
    input.fileId
    Type
    string
    Type
    Required
    Description

    File ID that serves as an input for this operation.

  • Name
    options
    Type
    object
    Type
    Optional
    Description

    An object that contains options for optimization operation.

  • Name
    options.conformance
    Type
    string
    Type
    Optional
    Description

    Claimed conformance of input document.

    Type
    Accepted values: pdf10, pdf11, pdf12, pdf13, pdf14, pdf15, pdf16, pdf17, pdf20, pdf_a1_b, pdf_a1_a, pdf_a2_b, pdf_a2_u, pdf_a2_a, pdf_a3_b, pdf_a3_u, pdf_a3_a
PDF conformance
pdf10PDF Version 1.0
pdf11PDF Version 1.1
pdf12PDF Version 1.2
pdf13PDF Version 1.3
pdf14PDF Version 1.4 (corresponds to Acrobat 5)
pdf15PDF Version 1.5
pdf16PDF Version 1.6 (corresponds to Acrobat 7)
pdf17PDF Version 1.7, ISO 32000-1
pdf20PDF Version 2.0, ISO 32000-2
pdf_a1_bPDF/A-1b, ISO 19005-1, level B conformance
pdf_a1_aPDF/A-1a, ISO 19005-1, level A conformance
pdf_a2_bPDF/A-2b, ISO 19005-2, level B conformance
pdf_a2_uPDF/A-2u, ISO 19005-2, level U conformance
pdf_a2_aPDF/A-2a, ISO 19005-2, level A conformance
pdf_a3_bPDF/A-3b, ISO 19005-3, level B conformance
pdf_a3_uPDF/A-3u, ISO 19005-3, level U conformance
pdf_a3_aPDF/A-3a, ISO 19005-3, level A conformance

Request

POST
/v1/operations/validate
curl -L -X POST 'https://api.pdf-tools.com/v1/operations/validate' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-Api-Key: <API_KEY_VALUE>' \
--data-raw '{
    "input": {
        "fileId": "<FILE_ID>"
    },
    "options": {
        "conformance": "pdf13"
    }
}'

Response

{
  "operationId": "f8418394-73f1-4ad4-8bb2-cda3ad9ff785",
  "operationType": "validate",
  "operationStatus": "inProgress"
}

Was this page helpful?