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.
[C#] Pdf pdf1 = new Pdf(); Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); Aspose.Pdf.Generator.Text text1 = new Text(sec1,"This is text in section1."); text1.Left = 30; text1.Top = 100; sec1.Paragraphs.Add(text1); Aspose.Pdf.Generator.Section sec2 = pdf1.Sections.Add(); Aspose.Pdf.Generator.Text text2 = new Text(sec2,"This is text in section2."); text2.Left = 30; text2.Top = 100; sec2.Paragraphs.Add(text2); //image watermark Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(); image1.ImageInfo.File = "world.jpg"; image1.ImageInfo.ImageFileType = ImageFileType.Jpeg; image1.ImageScale = 0.1f; FloatingBox watermark1 = new FloatingBox(200,100); watermark1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Page; watermark1.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Center; watermark1.BoxVerticalPositioning = BoxVerticalPositioningType.Page; watermark1.BoxVerticalAlignment = BoxVerticalAlignmentType.Center; watermark1.Paragraphs.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.Shapes.Add(curve1); FloatingBox watermark2 = new FloatingBox(400,100); watermark2.Paragraphs.Add(graph1); //text watermark Text text3 = new Text("Text Watermark"); FloatingBox watermark3 = new FloatingBox(100,100); watermark3.Left = 50; watermark3.Top = 500; watermark3.Paragraphs.Add(text3); pdf1.Watermarks.Add(watermark1); pdf1.Watermarks.Add(watermark2); pdf1.Watermarks.Add(watermark3); pdf1.Save("WatermarkExample.pdf"); [Visual Basic] Dim pdf1 As Pdf = New Pdf() Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add() Dim text1 As Aspose.Pdf.Generator.Text = New Text(sec1,"This is text in section1.") text1.Left = 30 text1.Top = 100 sec1.Paragraphs.Add(text1) Dim sec2 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add() Dim text2 As Aspose.Pdf.Generator.Text = New Text(sec2,"This is text in section2.") text2.Left = 30 text2.Top = 100 sec2.Paragraphs.Add(text2) 'image watermark Dim image1 As Aspose.Pdf.Generator.Image = New Aspose.Pdf.Generator.Image() image1.ImageInfo.File = "world.jpg" image1.ImageInfo.ImageFileType = ImageFileType.Jpeg image1.ImageScale = 0.1f Dim watermark1 As FloatingBox = New FloatingBox(200,100) watermark1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Page watermark1.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Center watermark1.BoxVerticalPositioning = BoxVerticalPositioningType.Page watermark1.BoxVerticalAlignment = BoxVerticalAlignmentType.Center watermark1.Paragraphs.Add(image1) 'graph watermark Dim graph1 As Graph = New Graph(400,100) Dim posArr() As single = New single() {0,0,200,80,300,40,350,90} Dim curve1 As Curve = New Curve(graph1,posArr) graph1.Shapes.Add(curve1) Dim watermark2 As FloatingBox = New FloatingBox(400,100) watermark2.Paragraphs.Add(graph1) 'text watermark Dim text3 As Text = New Text("Text Watermark") Dim watermark3 As FloatingBox = New FloatingBox(100,100) watermark3.Left = 50 watermark3.Top = 500 watermark3.Paragraphs.Add(text3) pdf1.Watermarks.Add(watermark1) pdf1.Watermarks.Add(watermark2) pdf1.Watermarks.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 watermark)
Adds a new
FloatingBox object into the collection. |
void |
addPara(FloatingBox watermark)
Adds a new
FloatingBox object into the collection. |
void |
insert(FloatingBox watermarkToInsertAfter,
FloatingBox newWatermark)
Inserts a new
FloatingBox object into the collection after specified FloatingBox object. |
public void add(FloatingBox watermark)
Adds a new FloatingBox
object into the collection.
watermark
- The FloatingBox
object to be added.public void addPara(FloatingBox watermark)
Adds a new FloatingBox
object into the collection.
watermark
- 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.Copyright © 2016 Aspose. All Rights Reserved.