# Convert API

> **This information is outdated**
>
> This information is **outdated** and will be removed. See the new BankID Signing documentation here: [Convert API](https://docs.stoe.no/bankid-esign-provider/apis/signdoc/v1/convert-api.md)

The Convert API from Signdoc is used to convert a PDF document to a format that is compatible with BankID signing and the Signdoc API.

## API

### Get the list of supported conversion formats

#### Request

```
GET [signdoc-baseurl]/convert/pdf/specs
```

##### Headers

```
Content-Type: application/json
```

#### Response

List of currently supported PDF conversions.

```json
{
    "pdfSpecs": [
        "PDFA_2B"
    ]
}
```

### Convert a PDF document

#### Request

```
POST [signdoc-baseurl]/convert/pdf
```

##### Headers

```
    Authorization: Bearer [access_token]
    Content-Type: application/json
```

##### Body

JSON array of documents to be signed (minimum one).

The `pdf` field contains the PDF document to be converted Base64 encoded.

```json
{
  "documents": [
    {
      "pdf": "JVBER...",
      "pdfSpec": "PDFA_2B"
    }
  ]
}
```

#### Response

Results of the conversion, including any warnings or errors.

`conversionWarnings` contains an array of warnings that occurred during the conversion.

Possible values are:

```
VISUAL_DIFF("Visual differences in output PDF")
COLORANTS("Resolve name collisions of colorants")
OCG_REMOVED("Removed optional content groups (layers)")
TRANSP_REMOVED("Transparency removed")
XMP_REMOVED("Removed non convertible XMP metadata")
FONT_SUBST("Font substituted")
ACTION_REMOVED( "Removed interactive elements such as actions or annotations")
STRUCTURE_REMOVED("Structure removed")
```

Documents that could not be converted will have a list of errors in `conversionErrors`:

```
CORRUPT("Document is corrupt")
DOC_SIGNED("Document contains signatures")
EF_REMOVED("Embedded files removed")
GENERIC_ERROR("Unknown error")
DISABLED("PDF conversion is disabled")
```

> **Note**
>
> In CURRENT the response will always be DISABLED("PDF conversion is disabled") and "converted" = false

```json
{
    "conversionResults": [
        {
            "conversionId": "d886b218-af9f-4765-a9e1-d819fec6abbe",
            "description": "My order name - 1",
            "converted": true,
            "conversionErrors": [],
            "conversionWarnings": [
                "Visual differences in output PDF",
                "Removed interactive elements such as actions or annotations"
            ],
            "convertedDocument": "JVBERi0xLjcKJ"
        },
        {
            "conversionId": "1b4c673a-9d9e-4680-8aa2-810a31d50d8c",
            "description": "My order name - 2",
            "converted": true,
            "conversionErrors": [],
            "conversionWarnings": [
                "Visual differences in output PDF",
                "Removed interactive elements such as actions or annotations"
            ],
            "convertedDocument": "JVBERi0xLjcKJ"
        }
    ]
}
```
