We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to generate multiline image from text

Hello Team,

We are using aspose.Imaging using that we want to generate image from text. If text length is beyond some specific width then it should be wrap and should display text after that length into new line. How can i achieve it into .Net core. Please refer attached image for expected output. Please suggest.

Image.jpg (21.8 KB)

@siriussynoptek

Can you please explain your requirements further a bit that if the text is fixed or it is enclosed inside any container. As far as Aspose.Imaging is concerned, you can using Graphics class to add text to image file and render that file. Please visit the documentation link, Drawing Images using Graphics for your reference.

Hi Mudassir,

We are using Aspose.Imaging to merge two or more images. Our requirement is between two images we want to add variable length of text. So here we want to save that text as image which have width of max width from other two images and if width of text is higher than max width of other two images then text should wrap into next line. Then we will merge three images instead of two images. How can we achieve this? Our text is “Test B - Test A liquam efficitur nulla et risus tincidunt, non venenatis dolor hendrerit”. Please see attached image that is generated from above text.

text.jpg (5.9 KB)

@siriussynoptek

I have shared the possible option of using Graphic class for adding text inside image using Aspose.Imaging API. What you are requiring to have support of wrapping text and also to new line may not be possible. You can consider using new line feed character inside your string or ‘\v’ (soft enter) if that works to go to new line.

Hi Mudassir,

Thanks for quick reply.

When we try to merge jpg and svg image into single image, it’s giving us error. Below code throwing error. We have tried to load svg image using Aspose.Imaging.Image class instead of ResterImage but in that we had not found LoadArgb32Pixels method. Can you please guide us where and what we need to change here? For reference we have attached sample application.

using (RasterImage rasterImage = (RasterImage)Image.Load(imagePath))
{
Rectangle bounds = new Rectangle(0, stitchedHeight, rasterImage.Width, rasterImage.Height);
stitchedHeight += rasterImage.Height;
newImage.SaveArgb32Pixels(bounds, rasterImage.LoadArgb32Pixels(rasterImage.Bounds));
}

Aspose_Imaging.zip (301.0 KB)

@siriussynoptek

You are importing a vector image (SVG) to a Raster image. This transition is not directly possible.You may first need to convert your vector image (SVG) to raster and then try loading that the way you want. Can you please check following thread link for your kind reference.

Hi Mudassir,

We have tried to convert SVG to PNG using code snippet suggested by you. Using that we are able to convert SVG to PNG but we are facing issue of extra left and right margin(Red highlighted in output_1) and also observe that some of the graphics of original SVG file is missing in PNG(Red highlighted in output_2). How can we resolve this? Please suggest. We have also attach sample working application for same.
output_1.png (31.0 KB)
output_2.png (11.8 KB)
Aspose_Imaging.zip (320.8 KB)

@siriussynoptek

Can you please try opening your SVG files in our Groupdocs viewer. You can see the empty white margins to the left and right of your SVG images.

Hi Mudassir,

Can you please suggest how can we resolve below issue which is commented on 25, Jun 2021?

  • Some of the graphics of original SVG file is missing in PNG

@siriussynoptek

Can you please share the comparison snapshot that what elements were missing from SVG in respective PNG?

Hi Mudassir,

I have attached comparison snapshot. Please check red highlighted part.

Comparison.png (78.8 KB)

@siriussynoptek

I have created an issue with ID IMAGINGNET-4595 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.