Dear MuthuFrank,
Thanks for your feedback.
I checked the code in the Word document you provided, and found it could get image size with unit inch. One thing needs to be noticed is that the unit in PDF is point, when drawing image, the default unit is point.
- Code: Select all
PdfGridCellContentList lst = new PdfGridCellContentList();
PdfGridCellContent textAndStyle = new PdfGridCellContent();
textAndStyle.Image = PdfImage.FromFile(@"F:\image\image1.jpg");
float width = textAndStyle.Image.Width;
float height = textAndStyle.Image.Height;
float dpi = textAndStyle.Image.VerticalResolution;
float newWidthInch = width / dpi;
float newheightInch = height / dpi;
//1 inch = 72 points
textAndStyle.ImageSize = new SizeF(newWidthInch * 72, newWidthInch * 72);
//convert image size from pixel to point
//PdfUnitConvertor uinit = new PdfUnitConvertor();
//SizeF pageSize = uinit.ConvertFromPixels(new Size(width ,height), PdfGraphicsUnit.Point);
Note, in the latest
Spire.PDF Pack(Hot Fix) Version:4.6.4, we had changed the class name PdfGridCellTextAndStyleList to PdfGridCellContentList, PdfGridCellTextAndStyle to PdfGridCellContent. And from your code, I knew you were using old version.
Sorry there is no row style like PdfGridRowContent style, and you need to insert image cell by cell.
Any question, welcome to get it back to us.
Sincerely,
Betsy
E-iceblue support team