0

I am stamping multiple images in the PDF document being generated from my SharePoint app. The PDF generation & image is stamping is working fine, but the image is changing it's original width & height i.e. the image is getting stretched when added to the PDF.

Here is my code:

SPFile PendingimgFile = obj_sign.GetFile("PendingApproval");//Get Image
byte[] imgByte = PendingimgFile.OpenBinary(SPOpenBinaryOptions.None);
MemoryStream ms_img = new MemoryStream(imgByte);

iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(ms_img);
image.SetAbsolutePosition(HorizontalValue, verticalValue);

image.ScaleAbsolute(80f, 60f);

cb.AddImage(image);//PDF Content byte

I've gone through this

The image quality is becoming very poor due to stretching, following is the screenshot from the PDF File:

enter image description here

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
Alina Anjum
  • 1,178
  • 6
  • 30
  • 53
  • You call `image.ScaleAbsolute(80f, 60f)`, so you explicitly set the resulting image size to 80×60 user space units. If you don't want these dimensions, don't set them. – mkl Jun 22 '20 at 07:50
  • @mkl I have already tried the same,it didn't work – Alina Anjum Jun 22 '20 at 10:35
  • *"I have already tried the same,it didn't work"* - Probably you did something wrong. You have not mentioned yet the actual size of the bitmap (probably you should share it). You don't show what content byte the `cb` is. (Direct or under content of a page? Some arbitrary template? Some annotation appearance?) In particular you don't show whether it is subject to any transformations. – mkl Jun 22 '20 at 11:14

0 Answers0