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

Free Support Forum - aspose.com

ImageStamp size increase

Due to what I think is a bug when adding images to a pdf (images are inserted upside down) I have been forced to use ImageStamp.

After following a code example I can successfully insert an ImageStamp into my PDF document but it is completely the wrong size (larger than the oiginal).

Please could you advise on maintaing the original resolution of the image I am trying to insert.

Thanks

@sunnybeaches

Would you please share your sample image, code snippet and output PDF document with us. We will test the scenario in our environment and address it accordingly.

        Document document = new Document();

        var imageStream = new FileStream(brandingImagePath, FileMode.Open);

        for (int pageNumber = 1; pageNumber <= document.Pages.Count; pageNumber++)
        {
            //debug width height:
            var page = document.Pages[pageNumber];

            var brandingImage = new ImageStamp(imageStream);

            brandingImage.Background = true;
            brandingImage.XIndent = 10;
            brandingImage.YIndent = 10;
            brandingImage.Opacity = 1;

            // Add stamp to particular page
            page.AddStamp(brandingImage);
        }

        imageStream.Dispose();

Here you can see how the image is blurry and oversized compared to the original.

branded_132403190749379228.pdf (99.1 KB)
testimage.png (11.1 KB)

@sunnybeaches

We tried to set height/width of image stamp using following code snippet but could not get much success. The image still looked over sized in the output PDF:

var b = new Bitmap(imageStream);
brandingImage.Height = b.Height;
brandingImage.Width = b.Width;

Therefore, we have logged an issue as PDFNET-48587 in our issue tracking system for further investigation on this case. We will look into its details and keep you posted with the status of ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Ok, thanks for getting back to me. I am on a deadline to get some work finished so a quick response would be appreciated.

This is also happening for adding an ximage in a rectangle.

@sunnybeaches

The ticket has been logged recently in our issue tracking system and will be investigated/resolved on first come first serve basis. We are afraid that we cannot share any ETA at the moment until the ticket is fully investigated. However, as a workaround, you may please try specifying FixHeight and FixWidth values for ImageStamp in order to display it in your desired size. We will let you know as soon as the issue is resolved.

We are sorry for the inconvenience.