本文整理匯總了Java中com.aspose.words.Node類的典型用法代碼示例。如果您正苦於以下問題:Java Node類的具體用法?Java Node怎麽用?Java Node使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Node類屬於com.aspose.words包,在下文中一共展示了Node類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.aspose.words.Node; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/workingwithdocument/movingcursor/data/";
Document doc = new Document(dataPath + "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(dataPath + "AsposeMovingCursor.doc");
System.out.println("Done.");
}
示例2: main
import com.aspose.words.Node; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/workingwithdocuments/movingcursorindocs/data/";
Document doc = new Document(dataPath + "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(dataPath + "AsposeMovingCursor.doc");
System.out.println("Done.");
}
示例3: main
import com.aspose.words.Node; //導入依賴的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");
}
示例4: main
import com.aspose.words.Node; //導入依賴的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");
}