Hi team,
I have included the Aspose.PDF dll version 17.7.0.0 from Nuget packages in Visual Studio.
I am trying to convert a div HTML into PDF version with the below mention code in Aspose.
String html = “this is a link to a web site like <a href=“http://www.aspose.com/”>this.”;
//instantiate HtmlLoadOptions object and set desrired properties.
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 20;
//Load HTML string
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
//Save PDF file
doc.Save(“output.pdf”);
But the page is giving error file not found.No BreakPoint is also coming in Visual Studio from the htmlLoadOptions.But if I remove the above mention code then breakpoint is also coming.
I saw another example code
string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion();
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// Add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(dataDir + “resultant.html”);
// Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
// Enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;
text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;
// Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2);
// Specify the URL which serves as images database
pdf.HtmlInfo.ImgUrl = dataDir;
// Following properties are added from Aspose.Pdf for .NET 8.4.0
pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText;
pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true;
// Save the Pdf document
pdf.Save(dataDir + “HTML2pdf_out.pdf”);
But my version of dll even missing Aspose.Pdf.Generator namespace.
Kindly help if the problem is with the dll or I am missing something.
Regards,
Bidisha