Xref table fixes

This fixes four small, but important, bugs in the metadata of the PDF file according to the standard. 
I'm verifying the files using an online PDF validation tool: https://www.pdf-tools.com/pdf/validate-pdfa-online.aspx

Fixed are: 

* The xref offsets are now calculated correctly
* The header of the the PDF should have (if compressed) a 4 byte binary comment
* the startxref value is now correct
* Add an (optional) ID  with md5 hex digests to the trailer for IDing the PDF file. 

Note: There are still some failures in the PDF validation. This is as far as I got today.