We have been using Aspose.pdf dll to convert HTML documents into PDF. Version - 10.1.0.0. However, one particular HTML document is not getting converted, and a 0KB file is being generated. The HTML document uses the font family “Bradley Hand ITC.” Below is the HTML file. Could you please check and advise on the issue?
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");
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());
sr.Close();
text2.TextInfo.IsUnicode = fontEmbedded;
text2.IsHtmlTagSupported = true;
section.Paragraphs.Add(text2);
pdf.Save(“Test.pdf”));
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.