I am trying to make a program that can print orders from a website form as PDF. The issue I am experiencing is when I try to use any type of html to pdf or uri to pdf parser it returns a blank page with no data at all. (I have attempted online parsers and they also return a blank page).
The page I am trying to download as pdf is https://webportal.naviaq.no/final-report?OrderId= The page should throw a bunch JavaScript errors but you can ignore these as it is caused by the lack of an OrderId.
I have tried many different solutions but this is my current solution with the IronPdf package. The strange thing is that when I do a manual print of the page in my browser I am able to print it to PDF with no issues at all.
public class WebInteraction
{
public static void UriToPdf(Uri uri, string filename)
{
var Renderer = new ChromePdfRenderer();
string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
if (uri != null)
{
Renderer.RenderingOptions.EnableJavaScript = true;
Renderer.RenderingOptions.RenderDelay = 4000;
using var PDF = Renderer.RenderUrlAsPdf(uri);
PDF.SaveAs(path + $"\\{filename}.pdf");
}
}
}
The code should return a pdf file in your C:\Users\%username%\
folder.