package org.hccp.pdf; public class Document { private Header header; private Body body; private CrossReferenceTable xRefTable; private Trailer trailer; public Document() { header = new Header(); body = new Body(); xRefTable = new CrossReferenceTable(header, body); trailer = new Trailer(getCrossReferenceTableOffset()); trailer.setRoot(new IndirectObjectReference(new Numeric(1), new Numeric(0))); } public Numeric getCrossReferenceTableOffset() { return new Numeric(header.getValue().getBytes().length + body.getValue().getBytes().length); } public Body getBody() { return body; } public String getValue() { xRefTable.refresh(); trailer.setCrossReferenceTableOffset(this.getCrossReferenceTableOffset()); StringBuffer sb = new StringBuffer(); sb.append(header.getValue()); sb.append(body.getValue()); sb.append(xRefTable.getValue()); sb.append(trailer.getValue()); return sb.toString(); } }