PDFix Actions for accessibility offer a flexible, no-code solution for resolving accessibility issues through batch commands. Click here for more details on PDFix SDK Actions.
Users can define a sequence of actions in a JSON file, which are then executed in order on an open PDF document.
Actions for Non-Tagged Documents
A crucial step in resolving accessibility issues in a non-tagged PDF is generating a tag structure using autotagging. 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.
By default, this command follows a predefined configuration that performs a sequence of actions, including removing old tag structures, flattening form XObjects, embedding fonts, autotagging content, updating metadata, generating bookmarks from headings, and applying other necessary fixes to ensure PDF/UA compliance.
Executing the Command
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.
Make Accessible Command
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"
}
]
}
Customizing the Make Accessible Command
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.
Executing with a Custom Configuration
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"
}
]
}
]
}
Actions for Tagged documents
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: