Skip to main content
Skip table of contents

Generate print files

Following the Create Draft tutorial, we now describe how to generate a pdf print file of a given draft from a specific user. It is important that you know the user identifier to access this print file in the last step.

To get a print file you need to go through the following steps:

1. Schedule print file creation

First we call Method “api-ext/pdf-processing” with Postman and add authorization header that contains a combination of the word Bearer and API Key which is separated by a space.

In the Body we add the following JSON data and get back a preocessingId for this job. This id is important for checking the status of your batch job in the next steps.

Key

Value

draftIds

Here you can add a JSON Array with draftIds who you want to generate a print file.

stateChangedNotifyUrl

Here you can set a url to which printformer can notify you when your job has been processed.

This example data show you the structure of this notification. The draftStates contains every draftId from your batch job. The state show you if your print file generation was successful (processed), failed, in-process and pending.

CODE
{
    "processingId": "2fbda9ffcaf21098f78d425072945563",
    "draftStates": [
        {
            "draftId": "a275jii66mz1lbrh9dlg66enovuht01c",
            "state": "failed",
            "message": "'Title' document info field required in PDF/X"
        },
        {
            "draftId": "dylstgbyyvrmspdgqcud7tgmftrpmax0",
            "state": "processed",
            "message": null
        },
        {
            "draftId": "hlmhgh4udulx3icesnxdr988webpd3c6",
            "state": "in-process",
            "message": null
        },
        {
            "draftId": "ck6ccfkilxcxfh2wrw0dsi5caoexw1ov",
            "state": "pending",
            "message": "'Title' document info field required in PDF/X"
        },
        {
            "draftId": "t0dqj5hz1ldk2uwenpcylgz78fvz1v2x",
            "state": "failed",
            "message": "'Title' document info field required in PDF/X"
        }
    ]
}

2. Check status for you draft batch by processing id

If you don't want to be informed about the batch job via notify url you can also check the state manually with API Method “api-ext/pdf-processing/{processingId}”. This API Methode need to be called via GET.

3. Get print file with generate a JWT Token

After you get the information that your draft is processed you can get the printfile. For this you can use the method “api-ext/files/draft/{draft}/print”. It is important that you need to generate a JWT to login as the owner of this draft.

To generate a JWT Token we can use http://jwt.io to decode, verify and generate a token for our editor url in the next step.

We need the following informations to generate our JWT Token:

Attribut

Position

Example Value

Description

jti

Header

ONVS6545F7ABCDE

Random String that only can use one time

client

Payload

vD3rU3Qw

printformer API credentials

user

Payload

YNrcxoTy

the user with that you have created the draft

iat

Payload

1516239022

timestamp

After that you need to verify signature JWT with printformer API Key.

Now you can call your print file with the following url:

{printformer URL}/api-ext/files/draft/{draftId}/print?jwt={JWT Token}

Example URL:

CODE
https://testshop.demo.printformer.net/api-ext/files/draft/b0ad067db9a58dca4fd90eb291246e78/print?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImp0aSI6Ik9OVlM2NTQ1RjdBQkNEWiJ9.eyJjbGllbnQiOiJ2RDNyVTNRdyIsInVzZXIiOiJZTnJjeG9UeSIsImlhdCI6MTUxNjIzOTAyMn0.Px5tC7eTH_jRvhpKMANc9lkFzV7xOfEzLwtJbK-HY9o

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.