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

Free Support Forum - aspose.com

ImageStamp.XIndent versus form field.GetRectangle().LLX

I’d like to place an ImageStamp directly over a form field. I’m able to get the coordinates of the form field rectangle. The coordinates provided by the form field rectangle are: LLX, LLY, URX, URY, Width and Height. However, the ImageStamp object, unfortunately, doesn’t share the same positioning elements. It uses the less desirable XIndent, YIndent, Height and Width. XIndent is from the left and YIndent is from the bottom of the page.

I found that I cannot calculate the proper positioning for the XIndent and YIndent by using the form field rectangle coordinates. The coordinates are close but not exact, which leaves my pdf document looking sloppy. I would assume that they are based upon the same base coordinates but it doesn’t seem that way.

How can I position an ImageStamp directly on top of a form field rectangle, given the rectangle coordinates?

… get the field from AsposePdf.Forms.Field
var rect = field.GetRectangle(false);
int llx = Convert.ToInt32(rect.LLX);
int lly = Convert.ToInt32(rect.LLY);
int urx = Convert.ToInt32(rect.URX);
int ury = Convert.ToInt32(rect.URY);

AsposePdf.ImageStamp imageStamp = new AsposePdf.ImageStamp(memStreamImageOutput);
imageStamp.Background = true;
imageStamp.XIndent = llx;
imageStamp.YIndent = lly;
imageStamp.Height = ury - lly;
imageStamp.Width = urx- llx;

pdfDoc.Pages[1].AddStamp(imageStamp);

The image does not appear over the form field rectangle coordinates. Is the anchor of the imageStamp different from the form field anchor? Are there some sort of different coordinates for the ImageStamp? Can somebody lend a hand here?

thanks,
Rob

@rsondles

Thanks for contacting support.

Would you please share your sample PDF document and sample image (you are using for stamping) with us. We will test the scenario in our environment and address it accordingly. Please also share the field name, upon which you want to place the image.

Hi and thanks for your response. Here are the two documents that I’m working with for this problem. The field names that I’m using for this process are “BuyerSignature”, “CoBuyerSignature” and “DistributorSignature”. The same type of image will be placed in each form field location.

thanks,
Rob

SignatureRBuyer.png (3.8 KB)
UCFS035.pdf (261.1 KB)

@rsondles

Thanks for sharing sample PDF document and image file.

We have tested the scenario in our environment using your code snippet with Aspose.PDF for .NET 18.5 and noticed that the image was placed over the form field rectangle. For your reference, we have also attached an output PDF document as well. You may please check the output PDF file and let us know about your feedback. In case your requirements are different, you may please share the desired output sample with us, so that we can test the scenario accordingly.

ImageAtformField.pdf (321.6 KB)