Exception with message: The embedded font 'univers' is not found

Hi,

I am converting HTML string to PDF, (latest version of aspose.pdf) In my HTML string there is a font tag like below,

(see attachment for the file/string i’m converting)
That is causing the following exception message,
The embedded font ‘univers’ is not found. Make sure that you set correct path to the font file.

Whereas on my local machine univers font is installed. ( i debug my project with VS local)

So 2 questions:

  • Is it possible to set a kind of property which overrules this font with a standard sytem font when not found??

  • Or how i can set the correct path?? I already set an .imgUrl property for my images but can’t find something for fonts

*update: found this property through your documentation : .IsFontNotFoundExceptionThrown
This one is set to default “False” but doesn’t work.I’m getting the error

Hi Michel,


Thanks for using our products.

I have tested the scenario where I have used the following code snippet and as per my observations, NullReferenceException is being generated during conversion process. For the sake of correction, I have logged this
issue as
PDFNEWNET-36139 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

[C#]

// load HTML contents<o:p></o:p>

Aspose.Pdf.Document source = new Aspose.Pdf.Document(@"C:\pdftest\TestCase.html", new HtmlLoadOptions());

// save output as PDF format

source.Save(@“C:\pdftest\TestCase.pdf”);



PS, can you please share the code snippet which can help us in replicating the issue which you are getting.

See my attachment.

One file is the html string, the other one the simple code i use to generate the PDF

Error on pdf.save(): The embedded font 'univers' is not found. Make sure that you set correct path to the font file.

I tried an another solution. Instead of aspose.PDF, i used aspose.Word.

This worked perfect for me!

Dim byteArray As Byte()
byteArray = Encoding.UTF8.GetBytes(bodycontent)

                ' Bodycontent is the HTML string<br><br>Dim streamPDFBody As New MemoryStream(byteArray)

Dim PDFWord As Aspose.Words.Document
                <br><br>Dim Loadoptions As Aspose.Words.LoadOptions<br>
                Loadoptions = New Aspose.Words.LoadOptions()


Loadoptions.BaseUri = Left(HttpContext.Current.Request.Url.OriginalString, HttpContext.Current.Request.Url.OriginalString.LastIndexOf("/") + 1)

Loadoptions.Encoding = System.Text.Encoding.UTF8

Loadoptions.LoadFormat = Aspose.Words.LoadFormat.Html



PDFWord = New Aspose.Words.Document(streamPDFBody, Loadoptions)

                <br>Dim streamPDF As New MemoryStream


PDFWord.Save(streamPDF, Aspose.Words.SaveFormat.Pdf)

The generated document is the same as the HTML file and gives NO error on my fonts!

So there is a great difference between HTML conversion in aspose.PDF and aspose.WORD!!

MNI:
One file is the html string, the other one the simple code i use to generate the PDF

Error on pdf.save(): The embedded font ‘univers’ is not found. Make sure that you set correct path to the font file.

Hi Michel,

Thanks for sharing the resource files.

I have again tested the scenario and have observed that when trying to save the output in Stream object " The embedded font ‘univers’ is not found. Make sure that you set correct path to the font file."exception is being generated. For the sake of correction, I have associated this information with earlier logged issue PDFNEWNET-36139. The development team will definitely consider this scenario during the resolution of this problem. Please be patient and spare us little time. We apologize for this inconvenience.

MNI:

I tried an another solution. Instead of aspose.PDF, i used aspose.Word.

This worked perfect for me!

Dim byteArray As Byte()
byteArray = Encoding.UTF8.GetBytes(bodycontent)

                ' Bodycontent is the HTML string<br><br>Dim streamPDFBody As New MemoryStream(byteArray)

Dim PDFWord As Aspose.Words.Document
                <br><br>Dim Loadoptions As Aspose.Words.LoadOptions<br>
                Loadoptions = New Aspose.Words.LoadOptions()


Loadoptions.BaseUri = Left(HttpContext.Current.Request.Url.OriginalString, HttpContext.Current.Request.Url.OriginalString.LastIndexOf("/") + 1)

Loadoptions.Encoding = System.Text.Encoding.UTF8

Loadoptions.LoadFormat = Aspose.Words.LoadFormat.Html



PDFWord = New Aspose.Words.Document(streamPDFBody, Loadoptions)

                <br>Dim streamPDF As New MemoryStream


PDFWord.Save(streamPDF, Aspose.Words.SaveFormat.Pdf)

The generated document is the same as the HTML file and gives NO error on my fonts!

So there is a great difference between HTML conversion in aspose.PDF and aspose.WORD!!

Hi Michel,

Aspose.Words for .NET and Aspose.Pdf for .NET have separate document rendering engine and we have observed that for some cases, the output generated with Aspose.Words is bit better as compared to the output generated with Aspose.Pdf for .NET. For the time being, you may continue using Aspose.Words for HTML to PDF conversion.

The issues you have found earlier (filed as PDFNEWNET-36139) have been fixed in Aspose.Pdf for .NET 9.3.0.

Blog post for this release can be viewed over this link


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Michel,


In reference to above fix, we have fixed the issue in new DOM approach, to convert HTML to PDF. You can use following code snippet for the purpose.


string inFile = “36139.htm”;
string outFile = “36139.pdf”;
HtmlLoadOptions options = new HtmlLoadOptions();
options.InputIncoding = “windows-1252”;
Document doc = new Document(inFile, options);
doc.Save(outFile);

Please feel free to contact us for any further assistance.

Best Regards,