Convert HTML to PDF using Aspose.PDF for .NET - 0KB PDF file generated


We have been using Aspose.pdf dll to convert HTML documents into PDF.Version -
But one particular html document is not getting converted, a 0KB file is being generated.
The html document has font-family of - “Bradley Hand ITC”.Below is the html file.
Could you please check and advise on the issue ?


<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="" xmlns=""><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
/* Font Definitions */
	{font-family:"Bradley Hand ITC";
	panose-1:3 7 4 2 5 3 2 3 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
p.msonormal0, li.msonormal0, div.msonormal0
	font-family:"Times New Roman",serif;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
--></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" />
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">

<p class="MsoNormal"><span style="font-size:16.0pt;font-family:&quot;Bradley Hand ITC&quot;">Test Name<o:p></o:p></span></p>




Thanks for contacting support.

We have tested the scenario while using Aspose.Pdf for .NET 17.9 with following code snippet and were unable to notice the issue of 0KB file generation. The API generated valid PDF document. For your reference, we have also attached an output, generated by below code.

var loadoptions = new HtmlLoadOptions(dataDir);
Document doc = new Document(dataDir + "FontSpecific.html", loadoptions);//MergePDF(docList);
doc.Save(dataDir + "FontSpecific.pdf"); 

FontSpecific.pdf (23.4 KB)

Please note that you are using a quite old version of the API, whereas it is strongly and always recommended to use latest version. Please upgrade to latest version of the API and in case you still face any issue, please feel free to let us know.

Thanks for your reply Asad,we have now got the latest Aspose.Pdf dll - 17.9 version, but we can see that in the new version - Aspose.Pdf.Generator.Pdf is not there.We are using below code to convert html document into pdf -

Could you please advise what changes are required to use the latest version ?

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, sr.ReadToEnd());
text2.TextInfo.IsUnicode = fontEmbedded;
text2.IsHtmlTagSupported = true;


Thanks for your inquiry.

The old Aspose.Pdf.Generator approach has been obsoleted in the new version(s) of Aspose.Pdf and we strongly recommend to use Aspose.Pdf DOM approach. You may use HtmlFragment class, in order to add HTML string inside PDF at paragraph level. For more information, please visit “Add HTML String using DOM” article in our API documentation. In case you face any issue, please feel free to let us know.