How can I flatten a PDF document using PrizmDoc Viewer?

Question

What are the technical details/process of “Flattening” a PDF document?

Answer

It is possible to “Flatten” PDF documents in PrizmDoc Viewer. You can do this by converting the document to a raster format (TIFF is recommended for PDF conversion) using PrizmDoc’s Content Conversion Service, and then converting it back to PDF format. This will result in a PDF with a single layer and no hidden objects. However, this will usually lower the quality and increase the file size of PDFs that are largely text.

Here is an example workflow using the Workfile API and the Content Conversion Service API:

1. Create a WorkFile from PDF

POST {{pccisUrl}}/PCCIS/V1/WorkFile
Content-Type: application/octet-stream

{{file bytes}}

2. Initiate Conversion to TIFF

POST {{pccisUrl}}/v2/contentConverters
Content-Type: application/json

{
    "input": {
        "sources": [
            {
                "fileId": "{{fileId}}"
            }
        ],
        "dest": {
            "format": "tiff"
        }
    }
}

3. Poll until response[“state”] === “complete”

GET {{pccisUrl}}/v2/contentConverters/{{processId}}

4. Initiate Conversion from TIFF back to PDF

POST {{pccisUrl}}/v2/contentConverters
Content-Type: application/json

{
    "input": {
        "sources": [
            {
                "fileId": "{{fileId_from_Step3_output}}"
            }
        ],
        "dest": {
            "format": "pdf"
        }
    }
}

5. Poll again

GET {{pccisUrl}}/v2/contentConverters/{{processId}}

6. Download

GET {{pccisUrl}}/PCCIS/V1/WorkFile/{{fileId}}?ContentDispositionFileName={{desiredFileNameWithExtension}}