Try our conversational search powered by Generative AI!

download pdf with rotativa


I want the html page(content and images) to be converted to pdf.

My view is as below:

Download UrlAsPDF

and the controller as below:

public ActionResult UrlAsPDF(ContentReference contentLink)
var url = ServiceLocator.Current.GetInstance();
var pageUrl = url.GetVirtualPath(contentLink);

return new UrlAsPdf(pageUrl.ToString())
FileName = "test.pdf"

I could see the link on my page, when I clicked on it,

I am getting the error as:

Error: Failed loading page http://http//localhost:12345System.Web.Routing.VirtualPathData (sometimes it will work just to ignore this error with --load-error-handling ignore)
Exit with code 1 due to network error: HostNotFoundError

I am running this on my local machine. Are there any other settings I need to look into. the url(http://http//localhost:12345System.Web.Routing.VirtualPathData) seems to be incorrect.

May 23, 2016 18:50

Use pageUrl.VirtualPath instead of pageUrl.ToString()

May 24, 2016 8:10

No luck with that. I am getting the 'Error: Failed loading page http://http//localhost:12345testpage/  (sometiems it will work just to ignore this error with load-error-handling ignore)

Exit with code 1 due to network error: HostNotFoundError'

The url seems to be wrong. We can't have two http and there is no slash after the port number and pagetype.

May 24, 2016 11:02

Instead of using .GetVirtualPath, use 

GetUrl(new UrlBuilder(contentLink), ContextMode.Default);
May 24, 2016 11:36
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.