Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
JODF
>
Tutorial
> Strikethrough text
The following example shows how to apply strikethrough formatting to text.
import com.independentsoft.office.odf.AttributedText; import com.independentsoft.office.odf.Paragraph; import com.independentsoft.office.odf.TextDocument; import com.independentsoft.office.odf.styles.LineStyle; import com.independentsoft.office.odf.styles.LineType; import com.independentsoft.office.odf.styles.TextStyle; public class Example { public static void main(String[] args) { try { TextDocument doc = new TextDocument(); TextStyle strikeStyle = new TextStyle("T1"); strikeStyle.setTextLineThrough(LineType.SINGLE); strikeStyle.setTextLineThroughStyle(LineStyle.SOLID); doc.getAutomaticStyles().getStyles().add(strikeStyle); AttributedText strikeSpan = new AttributedText(); strikeSpan.setStyle("T1"); strikeSpan.add("This text is struck through"); Paragraph p1 = new Paragraph(); p1.add("Normal text and "); p1.add(strikeSpan); p1.add(" back to normal."); doc.getBody().add(p1); doc.save("c:\\test\\output.odt", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*