Hi,
The following C# code snippet results in a NullReferenceException when calling the Aspose.Pdf.Document constructur:
byte[] contentBytes = Encoding.UTF8.GetBytes(mbContent);
using(MemoryStream ms = new MemoryStream(contentBytes))
{
mailbodyDocument = new Document(ms, htmlLoadOptions);
}
The content of the variable mbContent is as follows:
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Aptos;}
@font-face
{font-family:"Segoe Print";
panose-1:2 0 6 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang="DE" link="#467886" vlink="#96607D" style="word-wrap:break-word"><div><p style="margin:1pt 2pt 3pt 4pt;"><span style="font-family: Calibri;font-size:12.0pt;color:black;mso-fareast-language:DE-AT">Von: Zoltan Krekus <zoltan.krekus@kendox.com></span></p><p style="margin:1pt 2pt 3pt 4pt;"><span style="font-family: Calibri;font-size:12.0pt;color:black;mso-fareast-language:DE-AT">Gesendet: 17.10.2024 08:38:52</span></p><p style="margin:1pt 2pt 3pt 4pt;"><span style="font-family: Calibri;font-size:12.0pt;color:black;mso-fareast-language:DE-AT">An: Adele Vance <AdeleV@368z6g.onmicrosoft.com></span></p><p style="margin:1pt 2pt 3pt 4pt;"><span style="font-family: Calibri;font-size:12.0pt;color:black;mso-fareast-language:DE-AT">Betreff: Test</span></p><p style="margin:1pt 2pt 3pt 4pt;"><span style="font-family: Calibri;font-size:12.0pt;color:black;mso-fareast-language:DE-AT">Anlagen: smime.p7s; </span></p><p style="margin:1pt 2pt 3pt 4pt;"><span style="font-family: Calibri;font-size:12.0pt;color:black;mso-fareast-language:DE-AT"> </span></p></div><div class="WordSection1"><p class="MsoNormal"><span style="font-family:"Segoe Print"">Test Mail<o:p></o:p></span></p></div></body></html>
The exception seems to be caused because of the font ‘Segoe Print’:
<span style="font-family:"Segoe Print"">
Simpy changing the html tag to e.g.:
<span style="font-family:"Calibri"">
fixes the problem.
The font is locally installed in Windows.
Any help is appreciated,
Thanks