Package org.odftoolkit.odfdom.doc

Examples of org.odftoolkit.odfdom.doc.OdfTextDocument.save()


  @Test
  public void testReadDocumentMeta() throws Exception {
    // create a new empty document
    OdfTextDocument textDoc = OdfTextDocument.newTextDocument(); // activiating metadata updates
    textDoc.save(ResourceUtilities.newTestOutputFile("DocForMetaTest.odt"));
    textDoc.close();
    // read empty document meta
    textDoc = (OdfTextDocument) OdfTextDocument.loadDocument(ResourceUtilities.getAbsolutePath("DocForMetaTest.odt"));
    OdfOfficeMeta meta = textDoc.getOfficeMetadata();
    Assert.assertNotNull(meta.getGenerator());
View Full Code Here


          }
        }
        count++;
      }

      oDoc.save(outpath);
      return oDoc;
    }
    else {
      throw new Exception("Could not read from resource");
    }
View Full Code Here

  @Test
  public void testReadDocumentMeta() throws Exception {
    // create a new empty document
    OdfTextDocument textDoc = OdfTextDocument.newTextDocument(); // activiating metadata updates
    textDoc.save(ResourceUtilities.newTestOutputFile("DocForMetaTest.odt"));
    textDoc.close();
    // read empty document meta
    textDoc = (OdfTextDocument) OdfTextDocument.loadDocument(ResourceUtilities.getAbsolutePath("DocForMetaTest.odt"));
    OdfOfficeMeta meta = textDoc.getOfficeMetadata();
    Assert.assertNotNull(meta.getGenerator());
View Full Code Here

    // Append text to the end of the document.
    odt.addText("This is my very first ODF test");

    // Save document
    odt.save("MyFilename.odt");
  }


  @Test
  @Ignore
View Full Code Here

    // insert an image: This is a class from the Document API
    OdfDrawImage image = (OdfDrawImage) frame.newDrawImageElement();
    image.newImage(new URI("./MySampleImage.png"));

    // Save file
    odt.save("ImageOut.odt");

    //********************************************************************
    // WIKI EXAMPLE III from http://odftoolkit.org/projects/odfdom/pages/Layers

    // Load Image
View Full Code Here

    // Insert new spreadsheet as sub document into the package within directory  "myOdsDirectoryPath/"
    odt.insertDocument(OdfSpreadsheetDocument.newSpreadsheetDocument(), "myOdsDirectoryPath");

    // Save file
    odt.save("ImageOut.odt");
  }
}
View Full Code Here

      createTableWithData(document);
      document.newParagraph();
      document.newParagraph("Table with string values:");
      createTableWithString(document);

      document.save(ResourceUtilities.newTestOutputFile("CreateTableCase.odt"));
    } catch (Exception e) {
      Logger.getLogger(TableTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

      document.newParagraph("Empty table:");
      OdfTable table = createEmptyTable(document);
      table.setWidth(width);
      Assert.assertTrue(Math.abs(width - table.getWidth()) < 3);

      document.save(ResourceUtilities.newTestOutputFile("TestSetGetWidth.odt"));

    } catch (Exception e) {
      Logger.getLogger(TableTest.class.getName()).log(Level.SEVERE, null, e);
      Assert.fail(e.getMessage());
    }
View Full Code Here

      document.newParagraph("Empty table:");
      OdfTable table = createEmptyTable(document);
      table.setTableName(tablename);
      Assert.assertEquals(tablename, table.getTableName());

      document.save(ResourceUtilities.newTestOutputFile("TestGetSetName.odt"));
      document.close();
      document = loadODTDocument("TestGetSetName.odt");
      table = document.getTableByName(tablename);
      Assert.assertNotNull(table);
      String tablename2 = table.getTableName();
View Full Code Here

    try {
      //new another table with the same name
      //an exception will be thrown
      OdfTable table2 = OdfTable.newTable(document);
      table2.setTableName(tablename);
      document.save(ResourceUtilities.newTestOutputFile("TestGetSetName.odt"));
      Assert.fail("should not save the tables with the same table name.");
    } catch (Exception e) {
      if (!e.getMessage().startsWith("The table name is duplicate")) {
        Assert.fail(e.getMessage());
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.