protected void doWriteTrailer(COSDocument doc) throws IOException, COSVisitorException
{
getStandardOutput().write(TRAILER);
getStandardOutput().writeEOL();
COSDictionary trailer = doc.getTrailer();
//sort xref, needed only if object keys not regenerated
Collections.sort(getXRefEntries());
COSWriterXRefEntry lastEntry = (COSWriterXRefEntry)getXRefEntries().get( getXRefEntries().size()-1);
trailer.setInt(COSName.getPDFName("Size"), (int)lastEntry.getKey().getNumber()+1);
trailer.removeItem( COSName.PREV );
/**
COSObject catalog = doc.getCatalog();
if (catalog != null)
{
trailer.setItem(COSName.getPDFName("Root"), catalog);
}
*/
trailer.accept(this);
getStandardOutput().write(STARTXREF);
getStandardOutput().writeEOL();
getStandardOutput().write(String.valueOf(getStartxref()).getBytes());
getStandardOutput().writeEOL();