hey,
I’m using the pdf library in order to convert a PDF to PNG.
When i run it on windows it works perfectly but once i use docker container that runs Linux i get the following exception:
Unhandled exception. System.Exception: No suitable system fonts found
at #=z1DrOFh79Dc8U9Flq8I7GvFzR_R$G.#=zKQpzbf74s4o3(#=zBKkE1cB2ATwjZFEAMzYMJZMBvvksIZzDyg== #=z2aDBcZc=)
at #=z1DrOFh79Dc8U9Flq8I7GvFzR_R$G.#=zDPfvUN8=(#=zoZbZ78XusXM_nzRHEWgXZbEII$uJO5J2GinSeIqR_PyD& #=zOVin65g=)
at Aspose.Pdf.Devices.ImageDevice.#=zDPfvUN8=(Page #=zIpbuGsQ=)
at Aspose.Pdf.Devices.PngDevice.Process(Page page, Stream output)
Here is my code:
var images = new List<byte[]>();
var image = new PngDevice(new Resolution(200));
var filePath = Environment.GetCommandLineArgs()[1];
var data = File.ReadAllBytes(filePath);
using var docStream = new MemoryStream(data);
using var pdfDocument = new Document(docStream);
for(int i = 1; i <= pdfDocument.Pages.Count; i++)
{
using var pageImageStream = new MemoryStream();
image.Process(pdfDocument.Pages[i], pageImageStream);
images.Add(pageImageStream.ToArray());
}
Console.WriteLine(“Finished converting”);
var resFilesPath = Environment.GetCommandLineArgs()[2];
for (int i = 0; i < images.Count; i++)
{
File.WriteAllBytes(@$"{resFilesPath}/image-{i}.png", images[i]);
}
Console.WriteLine(“Finished writing”);
Many thanks,
Shay.