Jacob Collins Jacob is the JPedal Product Manager and specialises in PDF creation and manipulation. He also develops Salesforce backend systems and contributes to marketing and support. Outside of work, he’s a 1900‑rated chess player, guitarist, and French learner.

Fix PDF files with the Arlington Model PDF Validator

4 min read

JPedal Java PDF library logo

The November release of JPedal (2026.11) adds a ‘fix mode’ to our Arlington Model PDF Validator. Until now the validator could only tell you what was wrong with a PDF file. In fix mode it can repair some of those issues itself and write out a fixed copy of the file.

What is the Arlington PDF Model?

The Arlington PDF Model is the PDF Association’s machine-readable version of the rules in the PDF specification. We added a validator for it to JPedal in August, and our post on PDF/A compliance in Java explains what the model covers and what the validator reports.

What fix mode fixes

Fix mode only makes a change when the model leaves no doubt about the result: a default value to add, an optional key that can be dropped, or an object that must be indirect. That gives it three kinds of fix.

  • If a required key or array element is missing and the model defines a default for it, fix mode adds it with that default. An associated file specification with no AFRelationship, for example, gets /Unspecified.
  • If an optional key holds a value of the wrong type, a value outside the permitted list, or one that breaks a special-case rule, fix mode deletes the key and leaves the viewer to use its default. A catalog with a PageLayout of /AnUndefinedOption loses that key, so the document opens in the default layout.
  • If the model says an object has to be indirect and the file writes it as direct, fix mode moves it out into a new indirect object. A font descriptor written inline inside its font dictionary is one example.

What fix mode does not fix

Anything outside those three cases stays in the issue list untouched. The validator won’t invent a value the model doesn’t supply, so a required key with no default, or a Widths array of the wrong length, stays as it is. If one of those leftover issues is an error, you don’t get a fixed file (see below).

Encrypted files aren’t supported, and passing one to fix mode throws an IOException.

How the fixed file is checked

After applying its fixes, the validator runs the full check again on the result. Any remaining error stops the file being written, but warnings and info messages don’t. That means the issues you get back describe the fixed file rather than the one you started with.

A file with nothing to fix is still written to the output location, as long as it has no errors.

Using fix mode from the command line

To use the command line you’ll need a copy of the model in TSV format. Clone or download the Arlington PDF Model repository and pass the location of its tsv/latest directory to --tsv.

Add --fix followed by an output directory. Fixed files keep their original names inside that directory, and your input files are left alone.

java -cp jpedal.jar org.jpedal.arlington.validate.PdfArlingtonValidator --tsv <path-to-arlington-tsv-dir> [--level LEVEL] --fix <output-dir> file1.pdf [file2.pdf ...]

For every change it makes, the validator prints a line in the form [FIXED] path-in-pdf (arlington-object-definition): fix-message. Any issues still left in the fixed file are listed after those lines.

[FIXED] Trailer/Root/PageLayout (Catalog): Removed optional key 'PageLayout' with an invalid value (Value of 'PageLayout' (/AnUndefinedOption) is not one of the permitted values [SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight])
[FIXED] Trailer/Root/Pages/Kids[0]/Resources/Font/F2/FontDescriptor (FontCIDType0): Moved direct object to indirect object 12 (Value must be an indirect reference (fn:MustBeIndirect) but is a direct object)
[FIXED] Trailer/Root/AF[0] (AFFileSpecification): Added default value /Unspecified (Required key/element 'AFRelationship' does not exist)
3 fix(es) applied, fixed file written to "fixed/file1.pdf"

Using fix mode in Java

The JPedal jar already includes the model, so there’s nothing extra to download. Load it, then pass PdfArlingtonValidator.fixFile() your input and an output location, which has to be a different file from the input. The input can be a File, a byte[] or an InputStream.

final Map<String, ArlingtonObject> model = ArlingtonModelLoader.loadClasspath("arlington-pdf-model");

final PdfArlingtonValidator.FixResult result = PdfArlingtonValidator.fixFile(new File("inputFile.pdf"), model, new File("outputFile.pdf"));

for (final AppliedFix fix : result.fixes()) {
    // Iterate over the fixes which were made
}
for (final ValidationIssue issue : result.issues()) {
    // Iterate over the issues which remain in the fixed file
}
if (!result.written()) {
    // Errors remain, so the fixed file was not written
}

Always check written() before using the output file. If it’s false, nothing was written, and the issues list tells you what’s still wrong.

Fixing large files

While the fixed file is being checked again, it’s kept in memory. Files over the memory cache threshold are spilled to an encrypted temp file in the output directory instead. The threshold defaults to 58MB, and you can change it:

PdfArlingtonValidator.setMemoryCacheThreshold(10_000_000); // 10MB

Download JPedal to get started

Download a JPedal jar from our website to start validating and fixing PDF files.

Resources

The Arlington validation tutorial covers validation and fix mode from both the Java API and the command line.

We can help you better understand the PDF format as developers who have been working with the format for more than 2 decades!