Stamp an Image on PDF

Hi,

I’ve been testing the Aspose.PDF Cloud API References, because I want to use the stamp function in an app I’m developing, but I couldn’t find a way it works, The responses I get, are Code 200, but the image doesn’t appear in the pdf, actually the size of the PDF grows up, telling me the API is doing something, but probably I’m making a mistake with the Json parameters.

The endpoint I’m using is: /pdf/{name}/stamps/image

This is the stamp’s body im using:
[
{
“Background”: true,
“HorizontalAlignment”: “None”,
“Opacity”: 1.0,
“Rotate”: “None”,
“RotateAngle”: 0,
“XIndent”: 0,
“YIndent”: 0,
“Zoom”: 0,
“FileName”: “FacturaA4.jpeg”,
“Width”: 0,
“Height”: 0,
“VerticalAlignment”: “None”,
“BottomMargin”: 0,
“LeftMargin”: 0,
“TopMargin”: 0,
“RightMargin”: 0
}
]

Thanks in advance :+1:

@acctecnologiaca

To stamp an image on a PDF using the Aspose.PDF Cloud API, you need to ensure that you are correctly specifying the parameters in your JSON body. Based on your provided code, it seems that you might be missing some key parameters that define the size and position of the stamp.

Here’s a sample JSON body that you can use to stamp an image on a PDF:

[
  {
    "Background": true,
    "HorizontalAlignment": "Center",
    "Opacity": 1.0,
    "Rotate": "None",
    "RotateAngle": 0,
    "XIndent": 100,
    "YIndent": 100,
    "Zoom": 1,
    "FileName": "/FacturaA4.jpeg",
    "Width": 200,
    "Height": 100,
    "VerticalAlignment": "Center",
    "BottomMargin": 0,
    "LeftMargin": 0,
    "TopMargin": 0,
    "RightMargin": 0
  }
]

Key Points:

  1. FileName: Ensure that the image file path is correct and that the image is uploaded to the server.
  2. Width and Height: Set these parameters to define the size of the stamp. If they are set to 0, the stamp may not appear as expected.
  3. XIndent and YIndent: These parameters determine the position of the stamp on the page. Adjust them according to where you want the stamp to appear.
  4. Zoom: This parameter can be used to scale the image stamp.

Example Code:

Here’s an example of how you might implement this in your application:

var imageStamp = new ImageStamp
{
    Background = true,
    FileName = "/FacturaA4.jpeg",
    Width = 200,
    Height = 100,
    XIndent = 100,
    YIndent = 100,
    Opacity = 1.0,
    Rotate = Rotation.None
};

var response = PdfApi.PostPageImageStamps("YourPdfFileName.pdf", pageNumber, new List<ImageStamp> { imageStamp }, folder: "YourFolderName");

Make sure to replace "YourPdfFileName.pdf" and "YourFolderName" with your actual PDF file name and folder name.

If you continue to experience issues, double-check the image file path and ensure that the image is correctly uploaded to the server before attempting to stamp it on the PDF.

Feel free to reach out if you have any further questions or need additional assistance!

I used the example you gave me, and nothing happend, I mean, the problem continues. What other problem could it be?

I found the problem, but now, I need to solve that one and I don’t find a way. The problem is, the pdf what I’m stamping comes with a white shape behind the text, and this shape, fill all the page, so that’s the reason I wasn’t seeing the stamp. Is there a way I could delete this shape?

Thanks