We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding text to an Image for an Approval Stamp

Hey there, I was hoping someone could help me out here. Our software company is currently in the process of trying to transfer our web application to use ASPOSE for the conversion / manipulation of Word Documents. I have run into an issue with trying to add text to an image. The previous conversion software we used simply had an “AddText” function that would allow you to add text to any image added. Basically, I am trying to implement an Approval stamp, which takes a give of an approval stamp and then adds in the dates that the proposal / protocol is approved for. The date would just be passed in as a string, and I am trying to find the best way of adding that string the the Approval Stamp jpg. I have attached an example of the approval stamp that I would like to create, and would like to put this in the top right corner of a document. Any help with this would be greatly appreciated.


Thanks!
Brett

Edit:
I have also attached the .jpg that is being manipulated. I would like to add the date to that as seen in the first picture. Thanks!

Hi Brett,


Thanks for your inquiry. I think, you can achieve this by grouping two Shape objects of type ShapeType.Image and ShapeType.TextPlainText. I have attached a sample output Word document here for your reference. Here is the draft code that is used to produce out.docx:

Document doc = new
Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Shape imgShape = new Shape(doc, ShapeType.Image);

using (Bitmap img = new Bitmap(@"C:\Temp\approved.jpg"))

{

imgShape.ImageData.SetImage(img);

imgShape.Width = 150;

imgShape.Height = 150;

imgShape.WrapType = WrapType.Square;

imgShape.BehindText = true;

}

Shape textShape = new Shape(doc, ShapeType.TextPlainText);

textShape.Width = 85;

textShape.Height = 45;

textShape.Left = 38;

textShape.Top = 80;

Paragraph para = new Paragraph(doc);

Run run = new Run(doc, "04-Jan-2012" + ControlChar.LineBreak + "03-Jan-2013");

run.Font.Bold=true;

run.Font.Color = Color.Navy;

para.Runs.Add(run);

textShape.AppendChild(para);

GroupShape gs = new GroupShape(doc);

gs.AppendChild(imgShape);

gs.AppendChild(textShape);

gs.Width = 150;

gs.Height = 150;

gs.CoordSize = new Size(150, 150);

builder.InsertNode(gs);

builder.Document.Save(@“C:\Temp\out.docx”);


Please let me know if I can be of any further assistance.

Best regards,