I am afraid I cannot share sample HTML, since this is not permitted. But I do no think you actually need a sample, it is just a question of the renderer also allows jquery etc. and renders the page including all scripts before saving it to PDF
Furthermore, we requested for a sample HTML because it would allow us to see what type of document you are trying to convert as earlier logged tickets already have some sample files with them which we will investigate and implement the functionality accordingly.
Please try to attach HTML with resources in .zip format so that we can test the scenario in our environment and address it accordingly. Also, you can try following code snippet with Aspose.PDF in order to render HTML content on a full page:
var htmlOptions = new HtmlLoadOptions(dataDir);
//htmlOptions.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
htmlOptions.IsRenderToSinglePage = true;
var document = new Document(dataDir + "equationBreakingHtml.html", htmlOptions);
document.Save(dataDir + "static.pdf");
I have changed my test to using cdn’s instead, so now all should be included.
I have attached both the html and the pdf output.
This is the c# code I am using:
var body = _renderer.RenderPartialToStringAsync("~/Views/Test/TestAsposeView2.cshtml", "").Result;
body = body.Insert(0, "<html><head><meta charset='utf-8' /><meta name='viewport' content='width=device-width, initial-scale=1.0' />" +
"<meta http-equiv='X-UA-Compatible' content='IE=edge;' />" +
"<body><div class='container body-content rlMainContent'>");
body += "</div></body></html>";
var htmlDoc = new Aspose.Html.HTMLDocument(body, ".");
var options = new PdfRenderingOptions();
string outputfile = @"C:\_BP\Development\AsposeTesting\notification2.pdf";
var device = new PdfDevice(options, outputfile);
var renderer = new HtmlRenderer();
We tried to set margins as zero and page width to maximum size but HTML content was not getting fit in output PDF while using Aspose.HTML for .NET 20.12 and following code snippet:
string file = dataDir + "notification.html";
Aspose.Html.Saving.PdfSaveOptions options = new Html.Saving.PdfSaveOptions();
options.PageSetup.AnyPage.Margin = new Html.Drawing.Margin(0);
options.PageSetup.AdjustToWidestPage = true;
using (var document = new Aspose.Html.HTMLDocument(file))
Aspose.Html.Converters.Converter.ConvertHTML(document, options, dataDir + "outputByAsposeHTML.pdf");
Therefore, we have logged an issue as HTMLNET-2901 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.
We are sorry for the inconvenience.
Yes, we noticed that as well and moved your post to the respective forum category. Please note that Aspose.HTML is recommended for usage if you are dealing with HTML files as it is specialized for such cases. You can also use Aspose.PDF if you want to perform further manipulations in PDF files.