0

I have a controller and Action set up the receive a object and display a table based on that model. Now I want to create a PDF based on the view. The way we create PDF's is to pass it a url and it builds an image from that.

So to get my table view I would call something like

  return View("HoldingFeeSearchPrint", _model);

but the code for my PDF dll uses something like this that takes a string URI:

  //the Doc is an Object that will turn into PDF
  theDoc.AddImageUrl(reportUrl); // this takes a string url

is there someway that I can turn the first line , where I am directly passing a model into a string version of my model?

note the model is an IEnumberable of a pretty big object ,

Scott Selby
  • 9,420
  • 12
  • 57
  • 96

1 Answers1

1

I could interpret your question in one of two ways.

Option 1: Are you trying to build a URL with query parameters filled in by model values, and having the PDF builder fetch the content at that URL as a separate HTTP request? In that case you don't want to use a view in the first place, just a custom URL builder method (you could probably reuse your existing routes). I don't think this is what you're doing, but it's not quite clear.

Option 2: Are you trying to pass the PDF builder a URL-encoded copy of the HTML rendered by the view? Assuming this is the case, techniques for getting a string rendering of a model-bound view are discussed in this question. And URL-encoding an HTML string is discussed on MSDN.

Community
  • 1
  • 1
Lars Kemmann
  • 5,509
  • 3
  • 35
  • 67