Convert Web page to Pdf for Printing with forms Authentication

Im working on a functionality to print the current web page referring the above link.

It is working for the normal sites, but not forms application which uses forms authentication.

Below is the link which I reffered

It says the functionailty is under development, Could you confirm this is released . ? I have latest version license of aspose total products.

Thanks

@nisharunstraight

Thanks for contacting support.

The referred feature has been being improved with every release of the API. However, due to different and dynamic structure of web pages, API may produce unexpected results. In such case, you may please provide us a HTML file or webpage URL so that we can test the scenario in our environment and address it accordingly.

4567 _ John Hwy 516 _ Template Search _ RS-CMS_files.zip (461.3 KB)

html.zip (194.0 KB)

Attched the html files and html and the output pdfWebFormPrint.pdf (207.3 KB)

And here is the Codeblock

 var myUri = new Uri("http://localhost:52261/TemplateSearch.aspx?CaseID=100503");
     

       
        var myWebRequest = WebRequest.Create(myUri);
        var myHttpWebRequest = (HttpWebRequest)myWebRequest;
        myHttpWebRequest.PreAuthenticate = true;
        myHttpWebRequest.Headers["Cookie"] = cookieshead;

     
        
        myHttpWebRequest.Accept = "application/json";

        myWebRequest.Timeout = Timeout.Infinite;
       // myWebResponse.KeepAlive = true;

        WebResponse myWebResponse =  myWebRequest.GetResponse();
       
        var responseStream = myWebResponse.GetResponseStream();
  
        var myStreamReader = new StreamReader(responseStream, Encoding.Default);
 
        string responseFromServer = myStreamReader.ReadToEnd();
        string authority = "http://localhost:52261/Styles/";
        MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseFromServer));
        Aspose.Pdf.HtmlLoadOptions options = new Aspose.Pdf.HtmlLoadOptions(authority);
         options.ExternalResourcesCredentials = CredentialCache.DefaultCredentials;


        // Load HTML file
        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(stream, options);

        options.PageInfo.IsLandscape = true;
        options.PageInfo.Margin = new Aspose.Pdf.MarginInfo(10, 10, 10, 10);
        options.PageInfo.Width = 30 * 72; // 30 inches
        

        MemoryStream pdfstream = new MemoryStream();


        pdfDocument.Save(pdfstream);

        pdfstream.Position = 0;

        string outputDocx = Server.MapPath("~/Templates/Temp/" + "WebFormPrint.pdf");
        System.IO.File.WriteAllBytes(outputDocx, pdfstream.ToArray());

@nisharunstraight

Thank you for elaborating it further.

We will appreciate if you can share a sample application containing SSCCE code along with necessary resources and data so that we may address your concerns and assist you efficiently.

Hi it would take longer for me create a sample application with all the resources in it, Meantime,could you quickly go through it help me figure out why style is not being loaded.

All m y styles are residing in Styles folder
Thanks,
Nisha

@nisharunstraight

An SSCCE version of sample application would help us assist you efficiently so please try to share it with us once ready. However, there appears no apparent problem while taking a look into attached data but we still have logged an investigation ticket with ID PDFNET-46515 in our issue management system and will let you know once any update will be available in this regard.