Good day to you all. I am trying to back up an element's graphics state (in my case it's a text object) to another GState object for some specific treatment, but the moment the iterator parses the next element my backed up GState changes dynamically. I know this problem is probably due to shallow copying but the same doesn't happen if I back up the fill color of the text. Is there a way to avoid copying the gState by reference and do a deep copy of it? Here is a snippet of what I'm basically doing:
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.