incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1163141 - /incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext
Date Tue, 30 Aug 2011 08:45:32 GMT
Author: devinhan
Date: Tue Aug 30 08:45:32 2011
New Revision: 1163141

URL: http://svn.apache.org/viewvc?rev=1163141&view=rev
Log:
add gettingstartguide page

Added:
    incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext   (with props)

Added: incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext?rev=1163141&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext Tue Aug 30
08:45:32 2011
@@ -0,0 +1,110 @@
+Title:Getting Start Guide
+Notice:    Licensed to the Apache Software Foundation (ASF) under one
+           or more contributor license agreements.  See the NOTICE file
+           distributed with this work for additional information
+           regarding copyright ownership.  The ASF licenses this file
+           to you under the Apache License, Version 2.0 (the
+           "License"); you may not use this file except in compliance
+           with the License.  You may obtain a copy of the License at
+           .
+             http://www.apache.org/licenses/LICENSE-2.0
+           .
+           Unless required by applicable law or agreed to in writing,
+           software distributed under the License is distributed on an
+           "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+           KIND, either express or implied.  See the License for the
+           specific language governing permissions and limitations
+           under the License.
+
+This start guide shows how to use the Simple ODF API to create a text document with image,
paragraph, list and table in OpenDocument format (ODF). In about 40 lines of code, you will
be able to produce an OpenDocument Format text document named HelloWorld.odt that looks like
this:
+
+![demo file][1]
+
+**Prerequisites**
+
+Simple ODF is written in Java, so you will need to have Java 1.5 or above installed on your
system. Make sure you download the SDK (software development kit), not just the runtime version
of Java.
+
+In this tutorial, you can build and run the application from the command line or IDE, such
as Eclipse. Anyway, you need to download the following three jars, store them in the "lib"
directory and add them into the classpatch.
+
+ 1. [Simple ODF 0.6.6][2].
+ 2. [ODFDOM 0.8.7][3].
+ 3. The Apache Xerces 2.9.1 or higher version (download from [Apache
+    Xerces][4] web site).
+
+In addition, you need to download [the resource file][5] of this demo.
+
+**Code**
+
+We write all of the code needed to create the document in the HelloWorld class. For simplicity,
the code is wrapped in main method directly, package declaration is omitted and hard code
is also included in this program. 
+ 
+
+import java.net.URI;
+
+	import org.odftoolkit.simple.TextDocument;
+	import org.odftoolkit.simple.table.Cell;
+	import org.odftoolkit.simple.table.Table;
+	import org.odftoolkit.simple.text.list.List;
+
+	public class HelloWorld {
+		public static void main(String[] args) {
+			TextDocument outputOdt;
+			try {
+				outputOdt = TextDocument.newTextDocument();
+			
+				// add image
+				outputOdt.newImage(new URI("odf-logo.png"));
+			
+				// add paragraph
+				outputOdt.addParagraph("Hello World, Hello Simple ODF!");
+			
+				// add list
+				outputOdt.addParagraph("The following is a list.");
+				List list = outputOdt.addList();
+				String[] items = {"item1", "item2", "item3"};
+				list.addItems(items);
+			
+				// add table
+				Table table = outputOdt.addTable(2, 2);
+				Cell cell = table.getCellByPosition(0, 0);
+				cell.setStringValue("Hello World!");
+			
+				outputOdt.save("HelloWorld.odt");
+			} catch (Exception e) {
+				System.err.println("ERROR: unable to create output file.");
+			}
+		}
+	}
+
+The TextDocument class has these convenient methods: 
+
+    // Creates a new text document that contains an empty paragraph.
+    	TextDocument.newTextDocument();
+    	// Puts the image at the given location at the end of the document.
+    	TextDocument.newImage(URI location)
+    	// Creates a new paragraph with the given content and appends it to the end of the document.
+        TextDocument.addParagraph(String content)
+    	// Creates a new, empty list and appends it to the end of the document you're building.
You can add items for this list.
+    	TextDocument.addList()
+    	// Creates a new table with columnCount columns and rowCount rows. You can get the cell
at given position and set its content.
+    	TextDocument.addTable(int columnCount, int rowCount);
+    	// Saves the document at the given path. 
+    	TextDocument.save(String path)
+
+**Building and Running**
+
+If you use Eclipse, you can just run this class as a Java Application. If you use command
line, please complie code and run it with the following commands:
+
+    javac -cp lib/odfdom-java-0.8.7.jar:lib/simple-odf-0.6.6.jar HelloWorld.java
+    java -cp lib/odfdom-java-0.8.7.jar:lib/simple-odf-0.6.6.jar:lib/xercesImpl.jar:. HelloWorld
+**Getting the Files**
+
+You can download the code and resources of this demo from [here][5].
+
+ 
+
+
+  [1]: images/helloworld.png
+  [2]: http://odftoolkit.org/projects/simple/downloads/download/0.6.6/simple-odf-0.6.6.jar
+  [3]: http://repo1.maven.org/maven2/org/odftoolkit/odfdom-java/0.8.7/odfdom-java-0.8.7.jar
+  [4]: http://xerces.apache.org/mirrors.cgi
+  [5]: http://simple.odftoolkit.org/helloworld.zip
\ No newline at end of file

Propchange: incubator/odf/site/trunk/content/odftoolkit/simple/gettingstartguide.mdtext
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message