TextStamp textStamp = new TextStamp(text);
textStamp.BottomMargin = 5;
textStamp.LeftMargin = 35;
To set margins for a TextStamp
or an image in inches, you can utilize the ConvertUtil
class provided by Aspose.Words. This class allows you to convert inches to points, which is the unit used for margins in the API.
Here’s how you can set the margins for a TextStamp
in inches:
using Aspose.Words;
using Aspose.Words.Drawing;
// Create a new document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a TextStamp
TextStamp textStamp = new TextStamp("Your text here");
// Set margins in inches
textStamp.BottomMargin = ConvertUtil.InchToPoint(0.5); // 0.5 inches
textStamp.LeftMargin = ConvertUtil.InchToPoint(1.0); // 1.0 inch
// Add the TextStamp to the document
builder.InsertNode(textStamp);
// Save the document
doc.Save("Output.docx");
In this example, the ConvertUtil.InchToPoint
method is used to convert the desired margin values from inches to points. You can adjust the values passed to this method to set the margins according to your requirements.
This approach ensures that you can specify margins in a more familiar measurement unit (inches) while still adhering to the underlying point system used by the Aspose.Words library.
@sagarjagdale Aspose.Words does not have TextStamp
class. It looks like your question is related to Aspose.PDF. Could you please confirm?