Hi all,
This is my first project using MigraDoc/PdfSharp. I am writing C# program converting excel workbook into pdf file.
I have a problem with image positioning. The main issue is that I can't find already drawn row height.
All what i can find to this moment is row height same as in Excel, but when I'm creating pdf and text wraps in a cell,
the row expands and the picture overlaps the text.
Currently I'm doing it using method with MigraDoc header. I'hv already tried doing it as a watermart in PdfSharp but I'hv had the same problem.
Do you have any idea how to solve this problem?
Thanks in advance
Here is the part of code:
Code:
List<ExcelDrawing> pictures = worksheet.Drawings.ToList();
Bitmap imageBmp = (drawing as ExcelPicture).Image as Bitmap;
imageBmp.Save(Application.StartupPath + "\\img.jpg");
var position_start_row = drawing.From.Row ;
var position_start_column = drawing.From.Column ;
MigraDoc.DocumentObjectModel.Shapes.Image himg = section.Headers.Primary.AddImage(Application.StartupPath + "\\img.jpg");
double imagePositionFromTop = 0;
double imagePositionFromLeft = 0;
for (int i = 0; i < position_start_column; i++)
{
imagePositionFromLeft += table.Rows[position_start_row].Cells[i].Column.Width;
}
//this is the only way i cant access row height, when i try to it in different way I always get 0
for (int i = 0; i < position_start_row + 1; i++)
{
imagePositionFromTop += table.Rows[i].Cells[position_start_column].Row.Height;
}
himg.Top = imagePositionFromTop;
himg.Left = imagePositionFromLeft;