Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Error while converting html page to pdf

$
0
0
Hi Team, 

I am trying to convert html page using url to pdf but this exception occures-

An unhandled exception of type 'System.ArgumentException' occurred in Aspose.Pdf.dll

Additional information: At most 4 text fragments can be added in evaluation mode.


Code:

  WebRequest request =WebRequest.Create("https://www.sec.gov/Archives/edgar/data/320193/000119312517003764/d307349ddefa14a.htm");
            // If required by the server, set the credentials.
            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.sec.gov/Archives/edgar/data/320193/000119312517003764/");

            Document pdfDocument = new Document(stream, options);

            options.PageInfo.IsLandscape = true;

            pdfDocument.Save( @"C:\HTMLtoPDF_DOM.pdf");

Viewing all articles
Browse latest Browse all 3131

Trending Articles