I'm having an issue with using FreeSpire.PDF.
I have the following snippet of code: (part of a conversion from tiff to pdf)
- Code: Select all
image.SelectActiveFrame(FrameDimension.Page, pageIndex);
using var currentImage = new MemoryStream();
image.Save(currentImage, ImageFormat.Bmp);
var img = PdfImage.FromStream(currentImage);
var orientation = img.Width > img.Height
? PdfPageOrientation.Landscape
: PdfPageOrientation.Portrait;
var page = doc.Pages.Add(SizeF.Empty, new PdfMargins(0), PdfPageRotateAngle.RotateAngle0, orientation);
var sw = Stopwatch.StartNew();
page.Canvas.DrawImage(img, 0, 0, page.Canvas.ClientSize.Width, page.Canvas.ClientSize.Height);
Console.WriteLine("Took {0} to Draw Image", sw.Elapsed);
When I use this on my windows development pc, it works great,
The tiff files are scans, so they are meant to be drawn full size on each page.
It produces a small pdf, with the tiff files correctly placed.
However, when I build for linux (target framework is net5.0), and run it there, it also produces the same file, but it is a lot slower.
On windows the console output is: Took 00:00:00.0827767 to Draw Image
But on linux it is: Took 00:00:01.9174227 to Draw Image
So instead of 80 milliseconds, it takes almost 2 seconds!
While writing this post, I think the issue is in libgdiplus on linux.
Do you have any idea on how to speed this up?
Thanks, Erik