Prompt
My PDF merge job is corrupting files, what should I check?
Latest observation
Oct 12, 2026
OpenAI APIWeb search: off
If a PDF merge job is producing corrupted files, the usual causes are in the merge tool, source PDFs, or file handling. Here’s a practical checklist to narrow it down:
1. Verify the source PDFs
- Open each input PDF individually to confirm it’s valid.
- Check whether the corruption happens only with certain files.
- Look for:
- encrypted/password-protected PDFs
- malformed PDFs
- PDFs generated by scanners or weird printers
- incremental-save PDFs or partially downloaded files
2. Check the merge library/tool
- Make sure you’re using a stable, current version.
- Common issues happen when mixing PDFs from different generators.
- If using a library, confirm you’re calling the correct API for:
- appending pages
- preserving metadata/bookmarks
- flattening forms if needed
3. Inspect file I/O handling
- Ensure all files are fully written before merging.
- Make sure you’re not:
- reading and writing the same file simultaneously
- merging from a stream that has already been consumed
- truncating output because the process exits too early
- Confirm binary mode is used when required.
4. Check concurrency and temp files
- If multiple jobs run at once, verify they don’t share temp filenames.
- Look for race conditions with:
- temporary PDFs
- output paths
- cleanup jobs deleting files too early
5. Validate output structure
- Try opening the merged file in multiple viewers.
- Use a PDF validator if available.
- Compare file size to expected size; a suspiciously tiny output often means an incomplete write.
6. Watch for memory issues
- Very large PDFs can fail if the merge job runs out of memory.
- Check logs for:
- OOM kills
- timeouts
- process restarts
- partial output generation
7. Handle unsupported content
Some PDFs include things that merge tools mishandle:
- embedded files
- annotations
- forms/XFA
- transparency layers
- unusual fonts
- object streams / linearized PDFs
8. Check permissions and filesystem problems
- Ensure the process can write the output path.
- Watch for:
- disk full
- network filesystem glitches
- antivirus locking files
- permission changes during the job
9. Reproduce with a minimal case
- Merge only 2 PDFs: one known-good, one suspected.
- If the issue disappears, the problem may be a specific file or size threshold.
- If it only fails with many files, suspect resource limits or ordering bugs.
10. Review logs and exceptions carefully
- Look for warnings that are easy to miss.
- Some libraries “succeed” while silently skipping broken pages or objects.
If you want, I can help you debug it more directly if you tell me:
- what language/library you’re using,
- how you merge the PDFs,
- and what “corrupted” means exactly (won’t open, missing pages, blank pages, file size zero, etc.).