public class Watermarks
extends com.aspose.ms.System.Collections.CollectionBase
Represents a collection of FloatingBox
,which lay upon other content for the identification purpose as watermark,
Only Image
,Graph
and Text
are allowed in FloatingBox
.
are added on each page.
[Java] Pdf pdf1 = new Pdf(); aspose.pdf.generator.Section sec1 = pdf1.getSections().add(); aspose.pdf.generator.Text text1 = new Text(sec1,"This is text in section1."); text1.setLeft ( 30); text1.setTop ( 100); sec1.getParagraphs().add(text1); aspose.pdf.generator.Section sec2 = pdf1.getSections().add(); aspose.pdf.generator.Text text2 = new Text(sec2,"This is text in section2."); text2.setLeft ( 30); text2.setTop ( 100); sec2.getParagraphs().add(text2); //image watermark aspose.pdf.generator.Image image1 = new aspose.pdf.generator.Image(); image1.getImageInfo().setFile ( "world.jpg"); image1.getImageInfo().setImageFileType ( ImageFileType.Jpeg); image1.setImageScale ( 0.1f); FloatingBox watermark1 = new FloatingBox(200,100); watermark1.setBoxHorizontalPositioning ( BoxHorizontalPositioningType.Page); watermark1.setBoxHorizontalAlignment ( BoxHorizontalAlignmentType.Center); watermark1.setBoxVerticalPositioning ( BoxVerticalPositioningType.Page); watermark1.setBoxVerticalAlignment ( BoxVerticalAlignmentType.Center); watermark1.getParagraphs().add(image1); //graph watermark Graph graph1 = new Graph(400,100); float[] posArr = new float[]{0,0,200,80,300,40,350,90}; Curve curve1 = new Curve(graph1,posArr); graph1.getShapes().add(curve1); FloatingBox watermark2 = new FloatingBox(400,100); watermark2.getParagraphs().add(graph1); //text watermark Text text3 = new Text("Text Watermark"); FloatingBox watermark3 = new FloatingBox(100,100); watermark3.setLeft ( 50); watermark3.setTop ( 500); watermark3.getParagraphs().add(text3); pdf1.getWatermarks().add(watermark1); pdf1.getWatermarks().add(watermark2); pdf1.getWatermarks().add(watermark3); pdf1.save("WatermarkExample.pdf"); [XML] <Pdf xmlns="Aspose.Pdf" > <Section ID="section1"> <Text Left="30" Top="100"> <Segment>This is text in section1.</Segment> </Text> </Section> <Section ID="section2"> <Text Left="30" Top="100"> <Segment>"This is text in section2."</Segment> </Text> </Section> <Watermark Width="200" Height="100" BoxHorizontalPositioning="Page" BoxHorizontalAlignment="Center" BoxVerticalPositioning="Page" BoxVerticalAlignment="Center"> <Image File="world.jpg" Type="jpeg" ImageScale="0.1" /> </Watermark> <Watermark Width="400" Height="100"> <Graph Width="400" Height="100"> <Curve Position="0 0 200 80 300 40 350 90" /> </Graph> </Watermark> <Watermark Width="100" Height="100" Left ="50" Top="500"> <Text > <Segment IsUnicode="true" FontSize="12">Text Watermark</Segment> </Text> </Watermark> </Pdf>
Constructor and Description |
---|
Watermarks() |
Modifier and Type | Method and Description |
---|---|
void |
add(FloatingBox newWatermark)
Adds a new
FloatingBox object into the collection. |
FloatingBox |
get_Item(int index)
Gets or sets a
Watermarks object from the collection according to object index. |
void |
insert(FloatingBox watermarkToInsertAfter,
FloatingBox newWatermark)
Inserts a new
FloatingBox object into the collection after specified FloatingBox object. |
public void add(FloatingBox newWatermark)
Adds a new FloatingBox
object into the collection.
newWatermark
- The FloatingBox
object to be added.public void insert(FloatingBox watermarkToInsertAfter, FloatingBox newWatermark)
Inserts a new FloatingBox
object into the collection after specified FloatingBox
object.
watermarkToInsertAfter
- The FloatingBox
object to insert after.
If this object is null, the new object will be inserted as the first member.newWatermark
- The FloatingBox
object to be inserted.public FloatingBox get_Item(int index)
Gets or sets a Watermarks
object from the collection according to object index.
get_Item
in interface com.aspose.ms.System.Collections.IList
get_Item
in class com.aspose.ms.System.Collections.CollectionBase
Copyright © 2014 Aspose. All Rights Reserved.