Hi,
I have image stream and used docBUilder.InsertImage(_stream)
but want to insert a page break before the image being inserted based on it is landscape or portrait. i.e.
- landscape figures own page in landscape > (3:1)
- landscape/portrait figures no own page < (2,99:1)
How do I achieve this ? Any help?
Thanks
Pradnya
@PradnyaR Aspose.Words do not provide API to work with images. You could use either .NET system classes to or some other third-party image processing libraries depending on the your target platform.
Here is the code how to get image width/height with .NET System.Drawing
:
Image image = Image.FromStream(stream);
Console.WriteLine($"{image.Width};{image.Height}");
I didn’t find anything like Image image = Image.FromStream(stream);
in C# but manged to achieve the requirement by adding page break always before docBUilder.InsertImage(_stream)
and at the end removed the last inserted page break if the figure is landscape i.e. width > 3.
Thanks for you support!
Pradnya
1 Like
@PradnyaR System.Drawing.Common package which contains System.Drawing.Image class may not be available on the platform you are using. As an alternative you could use SkiaSharp graphics library.