Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Mar 25, 2024 3:54 pm

Hi, I have .net 5 proyect and I am ussing spire office 9.2.
I am trying to resize and image, using the code below:


var placeHolder = document.FindStringInLine("{CompanyLogo}", false, false).FirstOrDefault();
var pictureContainer = placeHolder.GetAsOneRange().OwnerParagraph;
pictureContainer.Replace(new Regex("{CompanyLogo}"), "");

if (!string.IsNullOrEmpty((company.Logo ?? "").Trim()))
{
var bytes = await _fileStorage.FileToArray(company.Logo.Trim());
if (bytes.Length > 0)
{
var picture = pictureContainer.AppendPicture(bytes);
_logger.LogWarning($"{picture}");
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
_logger.LogWarning($"{picture.Width} - {picture.Height}");
//Scale picture to fit 200 width
if (picture.Width > 200)
{
//picture.Height = 200 * 100 / picture.Width;
//picture.Width = 200 * 100 / picture.Width;

picture.SetScale(200 * 100 / picture.Width, 200 * 100 / picture.Width);

//picture.WidthScale = 200 * 100 / picture.Width;
//picture.HeightScale = picture.WidthScale;
}
_logger.LogWarning($"{picture.Width} - {picture.Height}");
}
}


I upload the image I am using in the attached file.

The problem is: when I try the code on my local computer (Windows), the image resize is done fine,
but when I try to resize the image on a Ubuntu server, the image resize doesn't happen.
Does, because the width of the image and the height of the image it get is 0.

camilapm
 
Posts: 11
Joined: Mon Jan 29, 2024 11:55 am

Tue Mar 26, 2024 6:41 am

Hello,

Thanks for your inquiry.
For your issue, please install "SkiaSharp. NativeAssets. Linux" to your project through the nuget package manager and try again. If your problem still persists, please reply to us and we will further investigate.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Tue Mar 26, 2024 2:17 pm

Thx, the library works !!!

camilapm
 
Posts: 11
Joined: Mon Jan 29, 2024 11:55 am

Wed Mar 27, 2024 2:09 am

Hello,

Thanks for your feedback.
Glad to hear that. If you encounter any questions about our products in the future, please feel free to write to us at any time.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Doc