Reputation: 137
Background: Converting html form output to pdf using iText and want to have only selected value. If there are three options and user has selected option C as below, would like to show C only in pdf.
<input type="radio" name="test" value="A">A
<input type="radio" name="test" value="B">B
<input type="radio" name="test" value="C" checked="true">C
For above set of string, as only option "C" is selected, I would like to get following output:
<input type="radio" name="test" value="C">C
Basically, want to remove non selected node. Tried following way and did not get expected output.
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Element currentNode = null;
if(list.item(i).getNodeType() == Node.ELEMENT_NODE && list.item(i).getNodeName().equals("input") )
currentNode =(Element) list.item(i);
if(conditionDefinedForNotchecked && currentNode != null)
currentNode.getParentNode().removeChild(currentNode);
}
Upvotes: 0
Views: 40
Reputation: 658
I love iText, but I still found creating an intermediate HTML format made my life much easier, simply because HTML debugging/viewing is much more advanced than PDF.
Suggested process:
Upvotes: 1