Hi,
I’ve exploring aspose html to pdf in C# for converting my html reports in .net web application.
With trail pack , checking on our requirement .
Facing difficulties in authentication of session inside web app , while converting HTML to PDF via URL.
While session is still on , aspose converts the login page instead of actual url
How to pass session params in aspose to get the expected result?
PFB the c# code for references.
string url = "http://localhost:99375/home/Details?id=1008";
HtmlLoadOptions options = new HtmlLoadOptions(url);
options.PageInfo.IsLandscape = false;
options.PageInfo.Height = 842;
options.PageInfo.Width = 595;
options.PageInfo.Margin = new MarginInfo(40, 110, 40, 110);// L,B,R,T
options.PageInfo.AnyMargin = new MarginInfo(40, 110, 40, 110); // L,B,R,T
options.HtmlMediaType = HtmlMediaType.Print;
Document pdfDocument = new Document(GetContentFromUrlAsStream(url), options);
pdfDocument.Save("C:/Output.pdf");
private static Stream GetContentFromUrlAsStream(string url)
{
using (var httpClient = new HttpClient(handler))
{
return httpClient.GetStreamAsync(url).GetAwaiter().GetResult();
}
}