Skip to content

Filled PDF file is corrupted #84

@nmathew98

Description

@nmathew98

Hey!

I think the current implementation of pdfboxing.form/set-fields saves the document incorrectly, it looks like it does this each time a field is set instead of setting all the fields and then saving at the end. I was writing to a byte array output stream instead of a file

From my testing, this produces two issues:

  • the output file is really large (original file: 207KB, save for each field: 5+ MB, save at the end: 240KB)
  • the output file can be opened in Chrome but it shows as corrupted when using macOS Preview and iOS Preview

Not entirely sure why it works this but this is the fix:

Image

Reference:

Tested with:

  • pdfboxing: 0.1.14
  • macOS: 26.2
  • iOS: 26.2
  • Safari: 26.2
  • Chrome: 143.0.7499.170

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions