Hi, I am doing a small test:
I have a Docker container with a .net Core application
In the code-block below you find 2 functions, While debugging I see Succeeding pdf generator uses Helvetica as font.
But when trying to use the Failing method (html to pdf) it fails with a message saying Glyph Helvetica is not found.
What I want:
I want Html to be converted to a PDF using a .net core application hosted in a docker container
At forehand thanx!
Gijsbert
public static class DocumentCreator
{
public static byte[] Working(string html)
{
using MemoryStream memoryStream = new MemoryStream();
GemBox.Pdf.ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var document = new PdfDocument())
{
// Add a page.
var page = document.Pages.Add();
// Write a text.
using (var formattedText = new PdfFormattedText()
{
FontWeight = PdfFontWeight.Bold,
})
{
formattedText.Append("Tick");
page.Content.DrawText(formattedText, new PdfPoint(100, 700));
}
document.Save(memoryStream);
}
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
return bytes;
}
public static byte[] Fails(string html)
{
using MemoryStream memoryStream = new MemoryStream();
GemBox.Document.ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var htmlLoadOptions = new HtmlLoadOptions();
using (var htmlStream = new MemoryStream(htmlLoadOptions.Encoding.GetBytes(html)))
{
var document = DocumentModel.Load(htmlStream, htmlLoadOptions);
document.DefaultCharacterFormat.FontName = "Helvetica";
document.Save(memoryStream, new GemBox.Document.PdfSaveOptions());
}
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
return bytes;
}
}