Hi
when i pass to this sting to ,i will not get out pdf file,This is my code
Note: i want my own string and current system datetime in 2 lines in watermark
Pls reply asap
Regards
Hi
Hi Aravind,
Dim
pdfDocument As New Document()<o:p></o:p>
pdfDocument.Pages.Add()<o:p></o:p>
Dim str
As String = “This is sample string” + Environment.NewLine + DateTime.Now.ToString()<o:p></o:p>
Dim text
As New Facades.FormattedText(str)<o:p></o:p>
Dim
textStamp As New TextStamp(text)<o:p></o:p>
textStamp.RotateAngle
= 45<o:p></o:p>
'set
text properties<o:p></o:p>
textStamp.TextState.Font
= FontRepository.FindFont(“Arial”)<o:p></o:p>
Dim
strSize As String = “12”<o:p></o:p>
textStamp.TextState.FontSize
= Convert.ToSingle(strSize)<o:p></o:p>
textStamp.TextState.FontStyle
= FontStyles.Bold<o:p></o:p>
textStamp.TextState.FontStyle
= FontStyles.Italic<o:p></o:p>
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red)<o:p></o:p>
textStamp.HorizontalAlignment
= HorizontalAlignment.Center<o:p></o:p>
textStamp.VerticalAlignment
= VerticalAlignment.Center<o:p></o:p>
textStamp.VerticalAlignment
= VerticalAlignment.Bottom<o:p></o:p>
textStamp.Opacity
= 0.5<o:p></o:p>
'add
stamp to particular page<o:p></o:p>
For Each
page As Page In pdfDocument.Pages<o:p></o:p>
page.AddStamp(textStamp)<o:p></o:p>
Next<o:p></o:p>
pdfDocument.Save(dataDir + "Watermark_out.pdf")
In case if you need any further assistance please feel free to let us know.
Best Regards,
Hi
Hi Aravind,
Dim
pdfDocument As New Document()<o:p></o:p>
pdfDocument.Pages.Add()
Dim imageStamp As New ImageStamp(dataDir + "aspose1.png")
imageStamp.RotateAngle = 90
imageStamp.BottomMargin = 10
imageStamp.HorizontalAlignment = HorizontalAlignment.Center
imageStamp.VerticalAlignment = VerticalAlignment.Center
imageStamp.Opacity = 0.5
imageStamp.XIndent = 200
imageStamp.YIndent = 500
Dim str As String = DateTime.Now.ToString()
Dim text As New Facades.FormattedText(str)
Dim textStamp As New TextStamp(text)
'set text properties
textStamp.TextState.Font = FontRepository.FindFont("Arial")
Dim strSize As String = "12"
textStamp.TextState.FontSize = Convert.ToSingle(strSize)
textStamp.TextState.FontStyle = FontStyles.Bold
textStamp.TextState.FontStyle = FontStyles.Italic
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red)
textStamp.Opacity = 0.5
textStamp.YIndent = 480 - imageStamp.Height
textStamp.XIndent = 230
For Each page As Page In pdfDocument.Pages
page.AddStamp(imageStamp)
page.AddStamp(textStamp)
Next
pdfDocument.Save(dataDir + "Watermark_out.pdf")
In case of any further assistance please feel free to contact us.
Best Regards,
Hi
Hi Aravind,
Hi Aravind,
bpanchu:
But in our case HorizontalAlignment only center and VerticalAlignment may be Top or Center or Bottom and also RotateAngle may be 0 or 45 or 90 or 180 or 360 ,so how find set text below the image, only for VerticalAlignment is bottom then text can move to top of the image.And image dimension like 250*51.
Dim pdfDocument As New Document()<o:p></o:p>
pdfDocument.Pages.Add()
Dim
imageStamp As New ImageStamp(dataDir + “sample_image.png”)<o:p></o:p>
imageStamp.RotateAngle = 90
imageStamp.BottomMargin = 10
imageStamp.HorizontalAlignment = HorizontalAlignment.Center
imageStamp.VerticalAlignment = VerticalAlignment.Center
imageStamp.Opacity = 0.5
Dim str As String = DateTime.Now.ToString()
Dim text As New Facades.FormattedText(str)
Dim textStamp As New TextStamp(text)
'set text properties
textStamp.TextState.Font = FontRepository.FindFont("Arial")
Dim strSize As String = "12"
textStamp.TextState.FontSize = Convert.ToSingle(strSize)
textStamp.TextState.FontStyle = FontStyles.Bold
textStamp.TextState.FontStyle = FontStyles.Italic
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Red)
textStamp.Opacity = 0.5
textStamp.XIndent = 320
textStamp.VerticalAlignment = VerticalAlignment.Center
textStamp.RotateAngle = 90
For Each page As Page In pdfDocument.Pages
page.AddStamp(imageStamp)
page.AddStamp(textStamp)
Next
pdfDocument.Save(dataDir + "Watermark1_out.pdf")
Moreover I have also attached an output file generated by the above code. In case of any further assistance please feel free to contact us.
Best Regards,
Hi
Hi Aravind,
bpanchu:
Previous code for RotateAngle 90 and it works for Top,center and bottom,what about other RotateAngle and different VerticalAlignment
textStamp.Value
= “RotateAngle = 45 and VerticalAlignment =top”<o:p></o:p>
textStamp.RotateAngle = 45
imageStamp.RotateAngle = 45
textStamp.VerticalAlignment = VerticalAlignment.Top
imageStamp.VerticalAlignment = VerticalAlignment.Top
imageStamp.HorizontalAlignment = HorizontalAlignment.None
imageStamp.XIndent = 200
textStamp.XIndent = 260
RotateAngle = 45 and VerticalAlignment = Center
textStamp.Value = "RotateAngle = 45 and VerticalAlignment =Center"
textStamp.RotateAngle = 45
imageStamp.RotateAngle = 45
textStamp.VerticalAlignment = VerticalAlignment.Center
imageStamp.VerticalAlignment = VerticalAlignment.Center
imageStamp.HorizontalAlignment = HorizontalAlignment.None
imageStamp.XIndent = 200
textStamp.XIndent = 260
RotateAngle = 45 and VerticalAlignment = Bottom
textStamp.Value = "RotateAngle = 45 and VerticalAlignment =Bottom"
textStamp.RotateAngle = 45
imageStamp.RotateAngle = 45
textStamp.VerticalAlignment = VerticalAlignment.Bottom
imageStamp.VerticalAlignment = VerticalAlignment.Bottom
imageStamp.HorizontalAlignment = HorizontalAlignment.None
imageStamp.XIndent = 200
textStamp.XIndent = 260
textStamp.BottomMargin = imageStamp.Height + 10
RotateAngle = 360 and VerticalAlignment = Top
textStamp.Value = "RotateAngle = 360 and VerticalAlignment =Top"
textStamp.RotateAngle = 360
imageStamp.RotateAngle = 360
textStamp.VerticalAlignment = VerticalAlignment.Top
imageStamp.VerticalAlignment = VerticalAlignment.Top
textStamp.XIndent = 260
RotateAngle = 360 and VerticalAlignment = Center
textStamp.Value = "RotateAngle = 360 and VerticalAlignment =Center"
textStamp.RotateAngle = 360
imageStamp.RotateAngle = 360
textStamp.VerticalAlignment = VerticalAlignment.Center
imageStamp.VerticalAlignment = VerticalAlignment.Center
textStamp.XIndent = 260
RotateAngle = 360 and VerticalAlignment = Bottom
textStamp.Value = "RotateAngle = 360 and VerticalAlignment =Bottom"
textStamp.RotateAngle = 360
imageStamp.RotateAngle = 360
textStamp.VerticalAlignment = VerticalAlignment.Bottom
imageStamp.VerticalAlignment = VerticalAlignment.Bottom
textStamp.XIndent = 260
textStamp.BottomMargin = imageStamp.Height
RotateAngle = 180 and VerticalAlignment = Top
textStamp.Value = "RotateAngle = 180 and VerticalAlignment =Top"
textStamp.RotateAngle = 180
imageStamp.RotateAngle = 180
textStamp.VerticalAlignment = VerticalAlignment.Top
imageStamp.VerticalAlignment = VerticalAlignment.Top
textStamp.XIndent = 260
RotateAngle = 180 and VerticalAlignment = Center
textStamp.Value = "RotateAngle = 180 and VerticalAlignment =Center"
textStamp.RotateAngle = 180
imageStamp.RotateAngle = 180
textStamp.VerticalAlignment = VerticalAlignment.Center
imageStamp.VerticalAlignment = VerticalAlignment.Center
textStamp.XIndent = 260
RotateAngle = 180 and VerticalAlignment = Bottom
textStamp.Value = "RotateAngle = 180 and VerticalAlignment =Bottom"
textStamp.RotateAngle = 180
imageStamp.RotateAngle = 180
textStamp.VerticalAlignment = VerticalAlignment.Bottom
imageStamp.VerticalAlignment = VerticalAlignment.Bottom
textStamp.XIndent = 260
textStamp.BottomMargin = imageStamp.Height
I have also attached an output which is generated by above code snippets for your reference.
bpanchu:
for all cases VerticalAlignment is bottom ,then text need to show top of the image.
You may check in the attached file that I have set the text stamp above the image in such cases where vertical alignment is set to bottom. Moreover I have also used an image with different dimensions for image stamp as you can see in the output file. I hope this will help you achieving the functionality as per your requirement. In case if you still face any issue please feel free to let us know.
Best Regards,
Thanks , All working fine, Thanks a lot…
Regards
Thanks for your feedback. It is good to know that suggested code worked for you.
Please keep using our API and feel free to contact us for any question or concern, we will be more than happy to extend our support.
Best Regards,