To generate a quality PDF document using the answer provided here, the length of written bytes should be calculated before the Writer
is done since it should be the value before w.write("%%EOFn")
.
How can the length of written bytes be read Eg. before line w.write("xrefn")
in the answer?