I am unable to create PDF file by URL using ASPOSE.PDF in C#,i am getting the following problem

i want to create PDF file by URL using ASPOSE.PDF and try the following code:

string dataDir =@"C:\Users\UbaidUllah\Documents\Visual Studio 2015\Projects\aspose\Data\AsposePDF\DocumentConversion\";
WebRequest request = WebRequest.Create("https://www.cricbuzz.com/cricket-stats/icc-rankings/men/batting");
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseFromServer));
HtmlLoadOptions options = new HtmlLoadOptions("https://www.cricbuzz.com/");
Document pdfDocument = new Document(stream, options);//----not execute this line nor give any error-----
pdfDocument.Save(dataDir + "WebPageToPDF_out.pdf");

when i debug this code, it does not go forward from the second last line(as described in comment) nor give any error, i wait much time but do not get any response.
I don’t know where the mistake is. please review the code and help me to solve the issue.
please also share the links by wich same task could be done by ther techniques:)
Thank you very much!

@ubaid

We apologize for the delayed response.

We noticed your similar inquiry at Stack Overflow and tested the scenario in an environment i.e. Windows 10 x64, Console Application (.NET Framework 4.7), Intel Core i5 processor, 8GB RAM. We were able to notice that the program hung up while consuming all available memory. We had to forcefully shut down the process.

It seems like an issue that API is unable to process provided HTML content. We tried an alternative method where we saved WebRequest response string as .html and tried to convert it to the PDF but, we got similar results i.e. program consumed all the memory and processor usage:

string responseFromServer = reader.ReadToEnd();
File.WriteAllText(dataDir + "input.html", responseFromServer);
Document pdfDocument = new Document(dataDir + "input.html", options);//----not execute this line nor give any error-----
pdfDocument.Save(dataDir + "WebPageToPDF_out.pdf");

We have registered an issue under the ticket ID PDFNET-48719 in our issue tracking system for the sake of correction. We will further investigate the reasons behind this behavior of the API and keep you posted with the status of its rectification. Please have patience and give us some time.

We apologize for your inconvenience.

1 Like

It’s OK…no problem.
Please can you share any other way(Code) by using which we can create PDF file by URL in C# using Aspose.pdf which works correctly right now?

if no other way besides this then please let me inform and I will wait.
Thank you for your support :slight_smile:

@ubaid

We already have tried an alternative way to generate PDF from the URL as shared in our previous reply. Regretfully, API does not offer a method other than that. We will surley inform you as soon as the respective logged ticket resolved. Please give us some time.

We apologize for your inconvenience.

1 Like

@asad.ali did you get any solution to create PDF file by URL?

@ubaid

The ticket was logged recently in our issue management system and is pending for review at the moment. It would definitely be investigated and resolved on first come first serve basis as it was reported under free support model. As soon as we have some progress updates about its resolution, we will inform you within this forum thread. Please have patience and give us some time.

We apologize for your inconvenience.