Search code examples
c#.netdocxnovacode-docx

C# .NET DocX Librairy : resize an image


I havent found anything in this librairy to resize an image. In the object Novacode.Image there is very few methods / properties and none of them seem to be usefull to resize an image.

If anyone has a clue on how to do it, it will be very usefull

Thank you


Solution

  • Ok, actually you cant resize the Novacode.Image object BUT you can do this :

    DocX document = DocX.Load("D:\\Template.docx");
    Novacode.Image drawing = document.AddImage(@"\images\img.png");
    Picture pic = drawing.CreatePicture();
    pic.Height = 340;
    pic.Width = 310;
    document.Paragraphs[0].InsertPicture(pic, 0);
    document.SaveAs(@"docs\TemplateCompleted.docx");