Hi Aspose team,
Hi Chandra,
//Open
document<o:p></o:p>
Document pdfDocument = new Document();
pdfDocument.Pages.Add();
//Create image stamp
ImageStamp imageStamp = new ImageStamp("c:/pdftest/watermark.jpeg");
imageStamp.Background = true;
imageStamp.Height = 80;
//imageStamp.Width = 300;
// add stamp at angle of 45 degree
imageStamp.RotateAngle = 45;
// set opacity for stamp object
imageStamp.Opacity = 0.5;
imageStamp.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
imageStamp.VerticalAlignment = VerticalAlignment.Center;
//Add stamp to particular page
pdfDocument.Pages[1].AddStamp(imageStamp);
//Save output document
pdfDocument.Save("c:/pdftest/CenterAligned_output.pdf");
Hi Team,
chandra Banda:
Thank you so much for your reply. But in my case I can not set the alignment manually, as my image size can vary from the front end. I have just given few settings in my code.
Do you need to get X,Y, Rotation angle for image once it has been added to PDF file ? Please note that unless the image is placed inside document, you cannot get information/properties associated with it.chandra Banda:
Please let me know, how can I get the position of x, y and rotation angle based on the page size and image size programatically.
Hi Team,
chandra Banda:
Thank you so much for the reply. we want to get the x, y and Rotation angle details before applying the image to pdf file. So that we can place that image in that postion on the pdf file.
My fellow workers from Aspose.Slides and Aspose.Words will further look into this query and will reply accordingly.chandra Banda:
And I want the same behaviour on Word, ppt files as well.
Thanks for your inquiry.
chandra Banda:
we want to get the x, y and Rotation angle details before applying the image to pdf file. So that we can place that image in that postion on the pdf file. And I want the same behaviour on Word, ppt files as well.
You can insert an image in Word document using DocumentBuilder.InsertImage. This method return the Shape node object. You can get the X, Y location and rotated angle of Shape node using following code example. Hope this helps you.
Document doc = new Document(MyDir + "in.docx");
LayoutCollector layoutCollector = new LayoutCollector(doc);
LayoutEnumerator layoutEnumerator = new LayoutEnumerator(doc);
var collection = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in collection)
{
var renderObject = layoutCollector.GetEntity(shape);
layoutEnumerator.Current = renderObject;
RectangleF location = layoutEnumerator.Rectangle;
Console.WriteLine("X : " + location.X + " Y : " + location.Y);
Console.WriteLine("Angle : " + shape.Rotation);
}
Please read the following article about inserting watermark in the word document.
http://www.aspose.com/docs/display/wordsnet/How+to++Add+a+Watermark+to+a+Document
Please note that Aspose.Words mimics the same behaviour as MS Word does. In your case, the image size (width) is greater then default page size. For this case, DocumentBuilder.InsertImage does not mimics the MS Word behavior. This is an issue and logged in our issue tracking system as WORDSNET-10718. We will update you via this forum thread once this issue is resolved. We apologize for your inconvenience.
If you still face problem, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.
The issues you have found earlier (filed as WORDSNET-10718) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)