GState backupGState = null;
while ((element = page_reader.next()) != null) {
switch (element.getType()) {
case Element.e_text: {
GState gs = element.getGState();
createTextField(backupGState);
backupGState = gs;
}
}
}
So after going into the while loop for the second time, the backupGState doesn't have the graphics state of the first element, but it changes dynamically to the state that the second element is in. This happens immediately after element = page_reader.next() is computed.