Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JODF
>
Tutorial
> Insert image
The following example shows you how to insert an image.
import com.independentsoft.office.odf.Paragraph; import com.independentsoft.office.odf.Size; import com.independentsoft.office.odf.TextDocument; import com.independentsoft.office.odf.Unit; import com.independentsoft.office.odf.drawing.Frame; import com.independentsoft.office.odf.drawing.Image; public class Example { public static void main(String[] args) { try { TextDocument doc = new TextDocument(); Image image1 = new Image("c:\\test\\image.jpg"); Frame frame1 = new Frame(); frame1.setWidth(new Size(6.67, Unit.INCH)); //640 pixels frame1.setHeight(new Size(5, Unit.INCH)); //480 pixels frame1.add(image1); Paragraph paragraph1 = new Paragraph(); paragraph1.add("Below is an image:"); Paragraph paragraph2 = new Paragraph(); paragraph2.add(frame1); doc.getBody().add(paragraph1); doc.getBody().add(paragraph2); 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*