Package com.aspose.words

Examples of com.aspose.words.Document


public class AsposeDocumentProperties
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/document.doc");
   
    System.out.println("============ Built-in Properties ============");
    for (DocumentProperty prop : doc.getBuiltInDocumentProperties())
        System.out.println(MessageFormat.format("{0} : {1}", prop.getName(), prop.getValue()));
   
    System.out.println("============ Custom Properties ============");
    for (DocumentProperty prop : doc.getCustomDocumentProperties())
        System.out.println(MessageFormat.format("{0} : {1}", prop.getName(), prop.getValue()));
   
    FileFormatInfo info = FileFormatUtil.detectFileFormat("data/document.doc");
    System.out.println("The document format is: " + FileFormatUtil.loadFormatToExtension(info.getLoadFormat()));
    System.out.println("Document is encrypted: " + info.isEncrypted());
View Full Code Here


public class AsposeCreateTable
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
   
    // We call this method to start building the table.
    builder.startTable();
    builder.insertCell();
    builder.write("Row 1, Cell 1 Content.");
   
    // Build the second cell
    builder.insertCell();
    builder.write("Row 1, Cell 2 Content.");
    // Call the following method to end the row and start a new row.
    builder.endRow();
   
    // Build the first cell of the second row.
    builder.insertCell();
    builder.write("Row 2, Cell 1 Content");
   
    // Build the second cell.
    builder.insertCell();
    builder.write("Row 2, Cell 2 Content.");
    builder.endRow();
   
    // Signal that we have finished building the table.
    builder.endTable();
   
    // Save the document to disk.
    doc.save("data/Aspose_CreateTable.doc");
  }
View Full Code Here

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

    Table table = builder.startTable();
    builder.insertCell();

    // Set the borders for the entire table.
    table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK);
    // Set the cell shading for this cell.
    builder.getCellFormat().getShading().setBackgroundPatternColor(Color.DARK_GRAY);
    builder.writeln("Cell #1");

    builder.insertCell();
    // Specify a different cell shading for the second cell.
    builder.getCellFormat().getShading().setBackgroundPatternColor(Color.blue);
    builder.writeln("Cell #2");

    // End this row.
    builder.endRow();

    // Clear the cell formatting from previous operations.
    builder.getCellFormat().clearFormatting();

    // Create the second row.
    builder.insertCell();

    // Create larger borders for the first cell of this row. This will be different
    // compared to the borders set for the table.
    builder.getCellFormat().getBorders().getLeft().setLineWidth(4.0);
    builder.getCellFormat().getBorders().getRight().setLineWidth(4.0);
    builder.getCellFormat().getBorders().getTop().setLineWidth(4.0);
    builder.getCellFormat().getBorders().getBottom().setLineWidth(4.0);
    builder.writeln("Cell #3");

    builder.insertCell();
    // Clear the cell formatting from the previous cell.
    builder.getCellFormat().clearFormatting();
    builder.writeln("Cell #4");

    doc.save("data/Aspose_styledTable.doc");
   
        System.out.println("Process Completed Successfully");
  }
View Full Code Here

public class AsposeFormattedText
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
   
    // Set paragraph formatting properties
    ParagraphFormat paragraphFormat = builder.getParagraphFormat();
    paragraphFormat.setAlignment(ParagraphAlignment.CENTER);
    paragraphFormat.setLeftIndent(50);
    paragraphFormat.setRightIndent(50);
    paragraphFormat.setSpaceAfter(25);

    // Output text
    builder.writeln("I'm a very nice formatted paragraph. I'm intended to demonstrate how the left and right indents affect word wrapping.");
   
    // Set font formatting properties
    Font font = builder.getFont();
    font.setBold(true);
    font.setColor(Color.BLUE);
    font.setItalic(true);
    font.setName("Arial");
    font.setSize(24);
    font.setSpacing(5);
    font.setUnderline(Underline.DOUBLE);

    // Output formatted text
    builder.writeln("I'm a very nice formatted string.");

    doc.save("data/Aspose_FormattedText.doc");
   
        System.out.println("Process Completed Successfully");
  }
View Full Code Here

public class AsposeMovingCursor
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/document.doc");
    DocumentBuilder builder = new DocumentBuilder(doc);

    //Shows how to access the current node in a document builder.
    Node curNode = builder.getCurrentNode();
    Paragraph curParagraph = builder.getCurrentParagraph();
   
    // Shows how to move a cursor position to a specified node.
    builder.moveTo(doc.getFirstSection().getBody().getLastParagraph());
   
    // Shows how to move a cursor position to the beginning or end of a document.
    builder.moveToDocumentEnd();
    builder.writeln("This is the end of the document.");

    builder.moveToDocumentStart();
    builder.writeln("This is the beginning of the document.");
   
    doc.save("data/AsposeMovingCursor.doc");
   
    System.out.println("Done.");
  }
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/AsposeImageInDoc.docx");
  }
View Full Code Here

public class AsposeNewDocument
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
    // DocumentBuilder provides members to easily add content to a document.
   
    DocumentBuilder builder = new DocumentBuilder(doc);
    // Write a new paragraph in the document with some text as "Sample Content..."
   
    builder.setBold(true);
   
    builder.writeln("Aspose Sample Content for Word file.");
   
    // Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
    // Aspose.Words supports saving any document in many more formats.
    doc.save("data/Aspose_NewDoc.docx",SaveFormat.DOCX);
  }
View Full Code Here

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

    // DocumentBuilder provides members to easily add content to a document.
    DocumentBuilder builder = new DocumentBuilder(doc);
   
    // Write a new paragraph in the document with some text as "Sample Content..."
    builder.writeln("Aspose Sample Content for Word file.");
   
    // Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
    // Aspose.Words supports saving any document in many more formats.
    doc.save("data/Aspose_SaveDoc.docx",SaveFormat.DOCX);
   
        System.out.println("Process Completed Successfully");
  }
View Full Code Here

public class AsposeOpenExistingDoc
{
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document("data/document.doc");
   
    // Save the document in DOCX format.
    // Aspose.Words supports saving any document in many more formats.
    doc.save("data/Aspose_SaveDoc.docx",SaveFormat.DOCX);
   
        System.out.println("Process Completed Successfully");
  }
View Full Code Here

{
  // See more @ http://www.aspose.com/docs/display/wordsjava/Bookmarks+in+Aspose.Words
 
  public static void main(String[] args) throws Exception
  {
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.startBookmark("AsposeBookmark");
    builder.writeln("Text inside a bookmark.");
    builder.endBookmark("AsposeBookmark");
   
    // By index.
    Bookmark bookmark1 = doc.getRange().getBookmarks().get(0);

    // By name.
    Bookmark bookmark2 = doc.getRange().getBookmarks().get("AsposeBookmark");
   
    doc.save("data/AsposebBookmark.doc", SaveFormat.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.