0

I'm generating a PDF file with MigraDoc. Now I need to add an image to the PDF, but if the image is bigger than the page, it is cut, as if part of it is outside the page. I tried to set the image width to a smaller size, but It's not working properly :

var sec = doc.AddSection();
var p = sec.AddParagraph();
var img = p.AddImage(imgFile);             
img.Width = "10cm";
img.LockAspectRatio = true;

But in the result PDF, it seems its ignoring the width I'm setting, It appears with the same size it was before.


Found the solution, it was dumber then I thougt. I was testing in a small console applcation, but I was generating the pdf to "Result2.pdf" and opening "Result.pdf". Sorry.

Marlon
  • 1,719
  • 3
  • 20
  • 42
  • Seems like a duplicate of this post, have you checked this out? https://stackoverflow.com/questions/31301226/fit-image-onto-one-pdf-page-using-migradoc – Jay Mason Aug 31 '20 at 15:46
  • Try doing `img.Width = "10.0cm";` All the documentation I've seen for this uses a decimal, even if it was a whole number. – ChilliPenguin Aug 31 '20 at 15:50

0 Answers0