November Happy Hour will be moved to Thursday December 5th.

download pdf with rotativa

Vote:
 

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:

[HttpGet]
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.

#148772
May 23, 2016 18:50
Vote:
 

Use pageUrl.VirtualPath instead of pageUrl.ToString()

#148780
May 24, 2016 8:10
Vote:
 

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.

#148787
May 24, 2016 11:02
Vote:
 

Ah.
Instead of using .GetVirtualPath, use 

GetUrl(new UrlBuilder(contentLink), ContextMode.Default);
#148790
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.