Accessibility Actions

No-Code PDF Accessibility Automation

Fix PDF/UA & WCAG Compliance

PDFix Accessibility Actions provide a flexible, no-code solution for batch-processing PDF accessibility fixes. Simply define a sequence of actions in your remediation workflow in a JSON file, and let PDFix execute the commands automatically.

A crucial step in resolving accessibility issues in a non-tagged PDF is generating a tag structure using auto-tagging. To simplify this process, we have developed the Make Accessible Command, which includes a set of actions specifically designed to address common accessibility issues in non-tagged PDF documents.

For non-tagged documents, the Make Accessible Command automates:

  • Removal of old tag structures
  • Flattening of form XObjects
  • Font embedding
  • Auto-tagging of content
  • Updating metadata
  • Bookmark generation from headings
  • Other necessary fixes for PDF/UA Compliance

Using the Command-Line:

./pdfix_app make-accessible -i "input.pdf" -o "output.pdf"

Programmatically in Python:

pdfix = GetPdfix()
doc = pdfix.OpenDoc("path/to/doc.pdf", "")
cmd = doc.GetCommand()
cmdStm = pdfix.CreateMemStream()
command.SaveCommandsToStream(kActionMakeAccessible, cmdStm, kDataFormatJson, kSaveFull)
cmd.LoadParamsFromStream(cmdStm, kDataFormatJson)
cmdStm.Destroy()
command.Run()
doc.Save("path/to/out.pdf", kSaveFull)

See the complete code examples below.

The default configuration of the make-accessible command is defined by the following JSON file. Each action is provided with the default values.

{
    "name": "make_accessible",
    "commands": [
        {
            "name": "clear_structure"
        },
        {
            "name": "flatten_xobject"
        },
        {
            "name": "embed_font"
        },
        {
            "name": "add_missing_unicode"
        },
        {
            "name": "add_tags"
        },
        {
            "name": "set_language"
        },
        {
            "name": "set_title"
        },
        {
            "name": "set_display_doc_title"
        },
        {
            "name": "set_pdf_ua_standard"
        },
        {
            "name": "set_suspect_value"
        },
        {
            "name": "fix_oc_name"
        },
        {
            "name": "fix_media_clip_keys"
        },
        {
            "name": "create_bookmarks"
        }
    ]
}

Some documents require a customized set of actions. For example, if the document:

  • Contains transparent elements → flattening form XObjects may visually alter the document.
  • Is a PDF 2.0 file → updating metadata should refer to pdfua:part 2.

Users can create a custom JSON file with appropriate actions and parameters.

Using the Command-Line:

./pdfix_app make-accessible -i "input.pdf" -o "output.pdf" -c "path/to/custom/command.json"

Programmatically in Python:

pdfix = GetPdfix()
doc = pdfix.OpenDoc("path/to/doc.pdf", "")
cmd = doc.GetCommand()
cmdStm = pdfix.CreateFileStream("path/to/custom/command.json", kReadOnly)
cmd.LoadParamsFromStream(cmdStm, kDataFormatJson)
cmdStm.Destroy()
command.Run()
doc.Save("path/to/out.pdf", kSaveFull)

See the complete code examples below.

Example: Auto-Tag, Set Document Language, and Set PDF/UA Identifier

{
  "actions": [
    {
      "name": "add-tags"
    },
    {
      "name": "set_lang",
      "params": [
        {
          "name": "lang",
          "value": "en-US"
        }
      ]      
    },
    {
      "name": "set_pdf_ua_standard",
      "params": [
        {
          "name": "path",
          "value": "1"
        }
      ]
    }
  ]
}

Tagged PDFs may require a different set of commands, addressing accessibility issues identified in a validation report.

These actions may include:

  • Fixing headings
  • Adding missing spaces
  • Generating alt text or table summaries
  • Fixing lists
  • Deleting unnecessary tags
  • Other necessary corrections

The approach remains the same as for non-tagged documents, excluding methods that clean the document structure and auto-tag.

Example: Fixing Missing Document Title, Annotation Contents, Lists, and Invalid MCIDs

{
  "actions": [
    {
      "name": "set_title",
      "params": [
        {
          "name": "title_type",
          "value": "2"              # Retrieve title from the file name
        }
      ]      
    },
    {
      "name": "set_annot_contents",
      "params": [
        {
          "name": "annot_types",
          "value": "Link|Widget"
        },
        {
          "name": "alt_type",
          "value": "1"              # Use text from annotation bounding box
        }
      ]
    },
    {
      "name": "fix_list_tag"
    },
    {
      "name": "artifact_content",
      "params": [
        {
          "name": "object_types",
          "value": {
            "template": {
              "object_update": [
                {
                  "query": {
                    "$and": [
                      {
                        "$0_artifact": "false"
                      },
                      {
                        "$0_mcid": "-1"
                      }
                    ],
                    "param": [
                      "pds_object"
                    ]
                  },
                  "statement": "$if"
                }
              ]
            }
          }      
        },
        {
          "name": "artifact_type",
          "value": "0"              # Mark as an artifact
        }
      ]
    },
    {
      "name": "remove_content_marks",
      "params": [
        {
          "name": "object_types",
          "value": ".*"             # All tag types
        },
        {
          "name": "flags",
          "value": "0"              # Invalid MCIDs
        }
      ]
    }
  ]
}

For more available actions and parameter options, check Actions.

Code Examples

Links to full code examples: