|
Hello,
I have a code like this
public class Doc extends DefaultStyledDocument{
}
Doc doc= new Doc();
doc.insertString(0, "This is a working document", null);
AbstractDocument.AbstractElement rootElement = doc.createDefaultRoot();
Once I create a root element how do I assign or set its value from the doc string.Currently the element is blank.
thnaks
Pritha
|
|
|
|
|
Am not adding full code .. jus sample
import com.lowagie.text.*;
Paragraph pH = new Paragraph("Title",FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new Color(0, 0, 255)));
Paragraph pF1 = new Paragraph("Conditions Apply",FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0, 0, 255)));
Paragraph pF2 = new Paragraph("*Coupon Valid till 1 month of date issued",FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD, new Color(0, 0, 255)));
Paragraph pF3 = new Paragraph("*tamil translation");
Paragraph pNEXT = new Paragraph("\n");
Paragraph p3 = new Paragraph();
p3.add(new Chunk(""));
Chunk separator = new Chunk(new DottedLineSeparator());
p3.add(separator);
pH.setAlignment(Paragraph.ALIGN_CENTER);
document.add(pH);
document.add(pNEXT);
document.add(tab);
document.add(pNEXT);
document.add(pF1);
document.add(pF2);
document.add(p3);
//document;
document.add(pNEXT);
|
|
|
|
|
hello
thanks for your reply
I am using swing libraries and there i am able to create a leaf or a branch of a document but the leafelement doesnt seem to get added to the default root .
public class MyDoc extends DefaultStyledDocument {
protected void insertUpdate(AbstractDocument.DefaultDocumentEvent e,
AttributeSet attr){
Element root = getDefaultRootElement();
Element branchroot = new BranchElement(root, null);
branchroot = createBranchElement(root,null);
Element leafElement = new LeafElement(branchroot, null, 0,0);
leafElement = createLeafElement(branchroot,null,"p");
}
public Element createBranchElement(Element parent,AttributeSet a)
{
return super.createBranchElement(parent, a);
}
protected Element createLeafElement(Element parent,AttributeSet a, String arg) throws BadLocationException
{
return super.createLeafElement(parent, null, startOffset(arg),startOffset(arg)+5);
}
}
|
|
|
|