當前位置: 首頁>>代碼示例>>Java>>正文


Java NodeType類代碼示例

本文整理匯總了Java中com.aspose.words.NodeType的典型用法代碼示例。如果您正苦於以下問題:Java NodeType類的具體用法?Java NodeType怎麽用?Java NodeType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NodeType類屬於com.aspose.words包,在下文中一共展示了NodeType類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithtables/joiningtables/data/";
	
	// Load the document.
	Document doc = new Document(dataPath + "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(dataPath + "AsposeJoinTables.doc");
	
	System.out.println("Done.");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:25,代碼來源:AsposeJoiningTables.java

示例2: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithtables/autofitsettingstotable/data/";

	// Open the document
	Document doc = new Document(dataPath + "tableDoc.doc");
	
	Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
	// Autofit the first table to the page width.
	table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);

	Table table2 = (Table)doc.getChild(NodeType.TABLE, 1, true);
	// Auto fit the table to the cell contents
	table2.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);

	// Save the document to disk.
	doc.save(dataPath + "AsposeAutoFitTable_Out.doc");
	
	System.out.println("Process Completed Successfully");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:21,代碼來源:AsposeTableAutoFitSettings.java

示例3: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
   {
String dataPath = "src/asposefeatures/workingwithtext/extractcomments/data/";

Document doc = new Document(dataPath + "AsposeComments.docx");

ArrayList collectedComments = new ArrayList();

// Collect all comments in the document
NodeCollection comments = doc.getChildNodes(NodeType.COMMENT, true);

// Look through all comments and gather information about them.
for (Comment comment : (Iterable<Comment>) comments)
{
    System.out.println(comment.getAuthor() + " - " + comment.getDateTime() + " - "
	    + comment.toString(SaveFormat.TEXT));
}
System.out.println("Done.");
   }
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:20,代碼來源:AsposeExtractComments.java

示例4: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
   {
String dataPath = "src/asposefeatures/workingwithtext/removecomments/data/";

Document doc = new Document(dataPath + "AsposeComments.docx");

// Collect all comments in the document
NodeCollection comments = doc.getChildNodes(NodeType.COMMENT, true);
// Look through all comments and remove those written by the authorName author.
for (int i = comments.getCount() - 1; i >= 0; i--)
{
    Comment comment = (Comment) comments.get(i);
    if (comment.getAuthor().equalsIgnoreCase("Aspose"))
	System.out.println("Aspose comment removed");
	comment.remove();
}

doc.save(dataPath + "AsposeCommentsRemoved.docx");
System.out.println("Done...");
   }
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:21,代碼來源:AsposeRemoveComments.java

示例5: main

import com.aspose.words.NodeType; //導入依賴的package包/類
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())
		{
			String imageFileName = java.text.MessageFormat.format(
					"Aspose.Images.{0}{1}", imageIndex, FileFormatUtil
							.imageTypeToExtension(shape.getImageData()
									.getImageType()));
			shape.getImageData().save("data/asposeImages/" + imageFileName);
	
			imageIndex++;
		}
	}
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:21,代碼來源:AsposeExtractImages.java

示例6: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithtables/joiningtables/data/";
	
	// Load the document.
	Document doc = new Document(dataPath + "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(dataPath + "AsposeJoinTables.doc");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_Java_for_Docx4j,代碼行數:23,代碼來源:AsposeJoiningTables.java

示例7: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithimages/extractimagesfromdocument/data/";

	Document doc = new Document(dataPath + "document.doc");
	
	NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
	int imageIndex = 0;
	for (Shape shape : (Iterable<Shape>) shapes)
	{
		if (shape.hasImage())
		{
			String imageFileName = java.text.MessageFormat.format(
					"Aspose.Images.{0}{1}", imageIndex, FileFormatUtil
							.imageTypeToExtension(shape.getImageData()
									.getImageType()));
			shape.getImageData().save(dataPath + imageFileName);
	
			imageIndex++;
		}
	}
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_Words_for_Apache_POI,代碼行數:23,代碼來源:AsposeExtractImages.java

示例8: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithtables/splittables/data/";
	
	// Load the document.
	Document doc = new Document(dataPath + "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(dataPath + "AsposeSplitTable.doc");
	
	System.out.println("Done.");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:36,代碼來源:AsposeSplittingTables.java

示例9: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	Document doc = new Document("data/document.doc");

	// This gets a live collection of all shape nodes in the document.
	NodeCollection shapeCollection = doc.getChildNodes(NodeType.SHAPE, true);

	// Since we will be adding/removing nodes, it is better to copy all collection
	// into a fixed size array, otherwise iterator will be invalidated.
	Node[] shapes = shapeCollection.toArray();

	for (Node node : shapes)
	{
	    Shape shape = (Shape)node;
	    // Filter out all shapes that we don't need.
	    if (shape.getShapeType() == ShapeType.TEXT_BOX)
	    {
	        // Create a new shape that will replace the existing shape.
	        Shape image = new Shape(doc, ShapeType.IMAGE);

	        // Load the image into the new shape.
	        image.getImageData().setImage("data/background.jpg");

	        // Make new shape's position to match the old shape.
	        image.setLeft(shape.getLeft());
	        image.setTop(shape.getTop());
	        image.setWidth(shape.getWidth());
	        image.setHeight(shape.getHeight());
	        image.setRelativeHorizontalPosition(shape.getRelativeHorizontalPosition());
	        image.setRelativeVerticalPosition(shape.getRelativeVerticalPosition());
	        image.setHorizontalAlignment(shape.getHorizontalAlignment());
	        image.setVerticalAlignment(shape.getVerticalAlignment());
	        image.setWrapType(shape.getWrapType());
	        image.setWrapSide(shape.getWrapSide());

	        // Insert new shape after the old shape and remove the old shape.
	        shape.getParentNode().insertAfter(image, shape);
	        shape.remove();
	    }
	}

	doc.save("data/AsposeReplaceTextboxesWithImages.doc");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:44,代碼來源:AsposeInsert.java

示例10: main

import com.aspose.words.NodeType; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithranges/insertbeforeandafterranges/data/";

	Document doc = new Document(dataPath + "document.doc");

	// This gets a live collection of all shape nodes in the document.
	NodeCollection shapeCollection = doc.getChildNodes(NodeType.SHAPE, true);

	// Since we will be adding/removing nodes, it is better to copy all collection
	// into a fixed size array, otherwise iterator will be invalidated.
	Node[] shapes = shapeCollection.toArray();

	for (Node node : shapes)
	{
	    Shape shape = (Shape)node;
	    // Filter out all shapes that we don't need.
	    if (shape.getShapeType() == ShapeType.TEXT_BOX)
	    {
	        // Create a new shape that will replace the existing shape.
	        Shape image = new Shape(doc, ShapeType.IMAGE);

	        // Load the image into the new shape.
	        image.getImageData().setImage(dataPath + "background.jpg");

	        // Make new shape's position to match the old shape.
	        image.setLeft(shape.getLeft());
	        image.setTop(shape.getTop());
	        image.setWidth(shape.getWidth());
	        image.setHeight(shape.getHeight());
	        image.setRelativeHorizontalPosition(shape.getRelativeHorizontalPosition());
	        image.setRelativeVerticalPosition(shape.getRelativeVerticalPosition());
	        image.setHorizontalAlignment(shape.getHorizontalAlignment());
	        image.setVerticalAlignment(shape.getVerticalAlignment());
	        image.setWrapType(shape.getWrapType());
	        image.setWrapSide(shape.getWrapSide());

	        // Insert new shape after the old shape and remove the old shape.
	        shape.getParentNode().insertAfter(image, shape);
	        shape.remove();
	    }
	}

	doc.save(dataPath + "AsposeReplaceTextboxesWithImages_Out.doc");
	System.out.println("Process Completed Successfully");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_Words_for_Apache_POI,代碼行數:47,代碼來源:AsposeInsert.java


注:本文中的com.aspose.words.NodeType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。