当前位置: 首页>>代码示例>>Java>>正文


Java Document.getChildNodes方法代码示例

本文整理汇总了Java中com.aspose.words.Document.getChildNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getChildNodes方法的具体用法?Java Document.getChildNodes怎么用?Java Document.getChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.aspose.words.Document的用法示例。


在下文中一共展示了Document.getChildNodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.aspose.words.Document; //导入方法依赖的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

示例2: main

import com.aspose.words.Document; //导入方法依赖的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

示例3: main

import com.aspose.words.Document; //导入方法依赖的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

示例4: main

import com.aspose.words.Document; //导入方法依赖的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

示例5: main

import com.aspose.words.Document; //导入方法依赖的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

示例6: main

import com.aspose.words.Document; //导入方法依赖的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.Document.getChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。