Package com.aspose.words

Examples of com.aspose.words.Document


public class AsposeTrackChanges
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/trackDoc.doc");
    doc.acceptAllRevisions();
    doc.save("data/AsposeAcceptChanges.doc", SaveFormat.DOC);
  }
View Full Code Here


public class AsposeFooters
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
      DocumentBuilder builder = new DocumentBuilder(doc);

      Section currentSection = builder.getCurrentSection();
      PageSetup pageSetup = currentSection.getPageSetup();

      // Specify if we want headers/footers of the first page to be different from other pages.
      // You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
      // different headers/footers for odd and even pages.
      pageSetup.setDifferentFirstPageHeaderFooter(true);

      // --- Create header for the first page. ---
      pageSetup.setHeaderDistance(20);
      builder.moveToHeaderFooter(HeaderFooterType.FOOTER_FIRST);
      builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);

      // Set font properties for header text.
      builder.getFont().setName("Arial");
      builder.getFont().setBold(true);
      builder.getFont().setSize(14);
     
      // Specify header title for the first page.
      builder.write("(C) 2001 Aspose Pty Ltd. All rights reserved.");

      // Save the resulting document.
      doc.save("data/AsposeFooter.doc");
  }
View Full Code Here

public class AsposeExtractImages
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/document.doc");
   
    NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
    int imageIndex = 0;
    for (Shape shape : (Iterable<Shape>) shapes)
    {
      if (shape.hasImage())
      {
View Full Code Here

public class AsposeConvertToFormats
{
  public static void main(String[] args) throws Exception
  {
        // Load the document from disk.
        Document doc = new Document("data/document.doc");
       
        doc.save("data/html/Aspose_DocToHTML.html",SaveFormat.HTML); //Save the document in HTML format.
        doc.save("data/Aspose_DocToPDF.pdf",SaveFormat.PDF); //Save the document in PDF format.
        doc.save("data/Aspose_DocToTxt.txt",SaveFormat.TEXT); //Save the document in TXT format.
        doc.save("data/Aspose_DocToJPG.jpg",SaveFormat.JPEG); //Save the document in JPEG format.
       
        System.out.println("Aspose - Doc file converted in specified formats");
  }
View Full Code Here

public class AsposeInsertImage
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.insertImage("data/background.jpg");
    builder.insertImage("data/background.jpg",
            RelativeHorizontalPosition.MARGIN,
            100,
            RelativeVerticalPosition.MARGIN,
            200,
            200,
            100,
            WrapType.SQUARE);
   
    doc.save("data/Aspose_InsertImage.docx");
   
        System.out.println("Process Completed Successfully");
  }
View Full Code Here

public class AsposeSplittingTables
{
  public static void main(String[] args) throws Exception
  {
    // Load the document.
    Document doc = new Document("data/tableDoc.doc");

    // Get the first table in the document.
    Table firstTable = (Table)doc.getChild(NodeType.TABLE, 0, true);

    // We will split the table at the third row (inclusive).
    Row row = firstTable.getRows().get(2);

    // Create a new container for the split table.
    Table table = (Table)firstTable.deepClone(false);

    // Insert the container after the original.
    firstTable.getParentNode().insertAfter(table, firstTable);

    // Add a buffer paragraph to ensure the tables stay apart.
    firstTable.getParentNode().insertAfter(new Paragraph(doc), firstTable);

    Row currentRow;

    do
    {
        currentRow = firstTable.getLastRow();
        table.prependChild(currentRow);
    }
    while (currentRow != row);

    doc.save("data/AsposeSplitTable.doc");
  }
View Full Code Here

public class AsposeRanges
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/document.doc");
    Range range = doc.getRange();
   
    String text = range.getText();
    System.out.println("Range: " + text);
  }
View Full Code Here

public class AsposeDeleteRange
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/document.doc");
    doc.getSections().get(0).getRange().delete();
   
    String text = doc.getRange().getText();
   
    System.out.println("Range: " + text);
  }
View Full Code Here

public class AsposeHeaders
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
      DocumentBuilder builder = new DocumentBuilder(doc);

      Section currentSection = builder.getCurrentSection();
      PageSetup pageSetup = currentSection.getPageSetup();

      // Specify if we want headers/footers of the first page to be different from other pages.
      // You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
      // different headers/footers for odd and even pages.
      pageSetup.setDifferentFirstPageHeaderFooter(true);

      // --- Create header for the first page. ---
      pageSetup.setHeaderDistance(20);
      builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
      builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);

      // Set font properties for header text.
      builder.getFont().setName("Arial");
      builder.getFont().setBold(true);
      builder.getFont().setSize(14);
      // Specify header title for the first page.
      builder.write("Aspose.Words Header/Footer Creation Primer - Title Page.");

      // Save the resulting document.
      doc.save("data/AsposeHeader.doc");
  }
View Full Code Here

public class AsposeJoiningTables
{
  public static void main(String[] args) throws Exception
  {
    // Load the document.
    Document doc = new Document("data/tableDoc.doc");

    // Get the first and second table in the document.
    // The rows from the second table will be appended to the end of the first table.
    Table firstTable = (Table)doc.getChild(NodeType.TABLE, 0, true);
    Table secondTable = (Table)doc.getChild(NodeType.TABLE, 1, true);

    // Append all rows from the current table to the next.
    // Due to the design of tables even tables with different cell count and widths can be joined into one table.
    while (secondTable.hasChildNodes())
        firstTable.getRows().add(secondTable.getFirstRow());

    // Remove the empty table container.
    secondTable.remove();

    doc.save("data/AsposeJoinTables.doc");
  }
View Full Code Here

TOP

Related Classes of com.aspose.words.Document

Copyright © 2018 www.massapicom. 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.