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

Free Support Forum - aspose.com

WebPage to Pdf Conversion problem

Hi My Web page has pure Html with some links to css and js files

<link href="../../bootstrap/less/bootstrap.less" type="text/css" rel="Stylesheet" /><link href="../../bootstrap/less/print.less" type="text/css" rel="Stylesheet" media="print" />

But currently when i use WebPage to Pdf approach It doesn’t sit right in Pdf

Here is my Code

public static void DownloadPdf(string encId, string code)

    var hostlink = ""; //proper link is sett here

    WebRequest request = WebRequest.Create(hostLink);
    request.Credentials = CredentialCache.DefaultCredentials;
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    Stream dataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(dataStream);

    string responseFromServer = reader.ReadToEnd();

    MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseFromServer));
    HtmlLoadOptions options = new HtmlLoadOptions(HttpContext.Current.Server.MapPath("~"));

    Document pdfDocument = new Document(stream, options);
    options.PageInfo.IsLandscape = true;
    pdfDocument.Save(HttpContext.Current.Server.MapPath(downloadPath + code + ".pdf"));

My web page is sample.png (63.3 KB)

but the pdf generated is pdf_of_sample.png (42.3 KB)


Thank you for contacting support.

I would like to request you to share the web page along with all necessary files including css,js files etc, or the link of web page if it can be accessed online. Also share the generated PDF file with us, in a single zipped file. Aspose.PDF renders a web page to a PDF document as it is displayed by a browser. Before sharing requested data, please ensure using Aspose.PDF for .NET 18.2 in your environment.