0

I am using EvoPDF html to pdf converter (v6.16) for .NET, and am attempting to generate the PDF using a localhost url. Please see an example of this below:

public void GeneratePDF()
{
  HtmlToPdfConverter converter = new HtmlToPdfConverter();
  converter.ConversionDelay = 4;

  // use ticks to give it a unique name.
  string pdfFileName = @"C:\pdf-files\" + DateTime.Now.Ticks.ToString() + ".pdf";

  try 
  {
    string url = "http://localhost:8080/index.html#!/";
    converter.ConvertUrlToFile(url, pdfFileName);
  }
  catch (Exception ex)
  {
    Console.Write(ex.Message);
  }
}

This works fine when I replace the url with one pointing to our live site, however for localhost it only outputs a blank pdf. This suggests the problem is specific to the use of a localhost url.

I have also already tried a number of different pages on the site running on localhost, each of them resulting in the same blank pdfs.

Have also tried changing the port that the site is running on locally to see if that made a difference, however still does not render out anything on the pdf.

I have done a fair bit of googling (enough to force me into asking a question on here) and not really turned up anything useful. I have already seen this question here, and it does not really provide any help.

Please note that I am also unable to get anything displaying on the pdf when I attempt to generate it using the localhost url on their demo application either.

Thanks in advance

Community
  • 1
  • 1
Mark
  • 459
  • 2
  • 12
  • Just to check a simple explanation: Does http://localhost:8080/index.html#!/ return the needed HTML data? I assume that the library will not produce meaningful PDF if the server returns a blank page. – Ralf Bönning Jul 19 '16 at 08:06
  • Yes it does. I have checked a number of pages of the site, all of which have information on which is rendered out to pdf perfectly well when accessed on the live site. – Mark Jul 19 '16 at 08:09

1 Answers1

0

Did you check the localhost URL can be loaded well in a browser on the browser where you run the conversion? It is possible that the localhost URLs cannot be accessed on the server itself.

Also, you cannot convert localhost URLs in the onlien demo on EvoPdf website because the localhost URLs from your server are not accessible on the EvoPdf server running the demo.

EvoPdf
  • 523
  • 3
  • 9