Splitting PDFs into multiple pages

By default, Blitline will automatically try to convert a source PDF into 1 large image. You do not need to do anything special to make this happen. 

{
    "application_id": "YOUR_APP_ID",
    "src": "https:\/\/s3.amazonaws.com\/bltemp\/non_stock_bulk_sell_sheet.pdf",
    "functions": [
        {
            "name": "resize_to_fit",
            "params": {
                "width": 200
            },
            "save": {
                "image_identifier": "external_sample_1"
            }
        }
    ]
}

If you want only the first page, you can use the Smart Image option (which sets smart defaults for you).

{
    "application_id": "YOUR_APP_ID",
    "src": "https:\/\/s3.amazonaws.com\/bltemp\/non_stock_bulk_sell_sheet.pdf",
    "src_type" : "smart_image",
    "functions": [
        {
            "name": "resize_to_fit",
            "params": {
                "width": 200
            },
            "save": {
                "image_identifier": "external_sample_1"
            }
        }
    ]
}

OR if you want a specific page out of the PDF you can use:

"srctype" : "multi_page"
"pages" : [ x, y,... ]
(where the array of pages are page index numbers)_

Like this:

{
    "application_id": "YOUR_APP_ID",
    "src": "https:\/\/s3.amazonaws.com\/blitdoc\/pdfs\/multi_page_sample.pdf",
    "src_type": {
        "name": "multi_page",
        "pages": [
            0,
            1
        ]
    },
    "v": 1.21,
    "functions": [
        {
            "name": "resize_to_fit",
            "params": {
                "width": 200,
                "height": 200
            },
            "save": {
                "image_identifier": "external_sample_1"
            }
        }
    ]
}

❗️

Multipage Limit

This option only supports pages up to 20. Any PDF that is larger than 20 must use the "burst" functionality below.

Burst PDF

📘

This is probably the option you want if you need to process multiple PDF pages.

Bursting allows you to explode the PDF into all the individual pages and run them all in parallel on Blitline’s massive image processing cloud. This allows HUGE PDF’s to be processed in a fraction of the time it would take to do it on your own machine or in a linear fashion.

Here is what happens behind the scenes:

  • Blitline downloads the src pdf
  • Blitline breaks the PDF into individual pages, and uploads these pages to a temp storge location
  • Blitline automatically creates a new “job” copying over the functions and data you have specified in the “burst_job”, for each page of the PDF, automatically renaming the output files to have a “__X” suffix (THAT IS 2 UNDERSCORES, NOT 1). Where X refers to page number.
  • Blitline will track the jobs and when they are all completed will issue a “postback” to your postback_url or put the item in the long polling cache.

To tell Blitline that you wish to burst a PDF, you must set the src_type to “burst_pdf”.

{
    "application_id": "YOUR_APP_ID",
    "src": "https://s3.amazonaws.com/bltemp/non_stock_bulk_sell_sheet.pdf",
    "src_type": "burst_pdf",
    "v": 1.2,
    "src_data": {
        "dpi": 200
    },
    "functions": [
        {
            "name": "resize_to_fit",
            "params": {
                "width": 500
            },
            "save": {
                "image_identifier": "external_sample"
            }
        }
    ]
}

The resulting RESPONSE will look like this:

{
    "results": {
        "images": [
            {
                "image_identifier": "MY_CLIENT_ID",
                "s3_url": "[[Your URL]]"
            }
        ],
        "job_id": "4ec2e057c29aba53a5000001",
        "group_completion_job_id": "B734Hasd23423llasda"
    }
}

Notice there is a group_completion_job_id, which is a “virtual job_id” indicating the completion of the group of jobs. You can poll this group_completion_job_id just as you would a regular job. It will also be the job_id of the postback when ALL the individual jobs are completed.

🚧

Important Output Info!

When outputting the PDF files, Blitline will automatically append two underscores (“”) and a page number to the filename. When you specify an s3_destination, Blitline will automatically output to your key + “” + (page number). This is a canonical format that Blitline uses.


❗️

Billing Alert

Bursting a page converts the PDF into multiple single pages. Each of these pages is then processed through Blitline. Each page will count as a regular job for billing purposes. So a PDF will be 1 premium job + X regular jobs (where X is the number of pages processed).