- Split writeXrefStream into smaller, focused functions
- Improve error handling and messages in xref related functions
- Enhance code readability and maintainability
- Use io.WriteString for more efficient string writing
This refactoring aims to make the xref stream writing process more modular, easier to understand, and slightly more efficient, while maintaining the existing functionality.
- Refactor xref table writing logic to correctly parse existing entries
- Add support for variable first object ID in xref table
- Implement dynamic calculation of new xref entries
- Improve error handling and reporting
This change resolves issue #4 with malformed xref tables when signing PDFs
that have undergone multiple revisions.