We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The document is not completely loaded. Please wait for 'complete' state

I am getting this error Ocassionally using your example code, happens when creating the PDF

Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“Aspose.PDF.NET.lic”);

HtmlLoadOptions options = new HtmlLoadOptions(url)
{
PageInfo = { Width = 842, Height = 1191, IsLandscape = true }
};
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(GetContentFromUrlAsStream(url), options);

private static Stream GetContentFromUrlAsStream(string url, ICredentials credentials = null)
{
using (var handler = new HttpClientHandler { Credentials = credentials })
using (var httpClient = new HttpClient(handler))
{
return httpClient.GetStreamAsync(url).GetAwaiter().GetResult();
}
}

@ARLSYS

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input URL.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Changed private static Stream GetContentFromUrlAsStream(string url, ICredentials credentials = null)
to not use GetStreamAsync(url).GetAwaiter().GetResult() and the problem went away.
apparently httpClient.GetStreamAsync(url).GetAwaiter().GetResult() doesn’t always wait for completion.

Below is the code that works

private static Stream GetContentFromUrlAsStream(string url, ICredentials credentials = null)
{
WebClient client = new WebClient();
byte[] bytes2 = client.DownloadData(url);
Stream stream = new MemoryStream(bytes2);
return stream;
}

@ARLSYS

It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.PDF, we will be happy to help you.