andyhutch77 / MvcRazorToPdf

Create pdf documents within an asp .net mvc project by generating your views as normal but returning a PdfActionResult. This converts regular produced razor/html to pdf documents in the browser using the iTextXmlWorker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting the string "MvcRazorToPdf.PdfActionResult" instead of the PDF

germanger opened this issue · comments

I'm getting the string "MvcRazorToPdf.PdfActionResult" instead of the PDF itself:

pdfactionresult

My controller's code is this:

            return new PdfActionResult(packing, (writer, document) =>
            {
                document.SetPageSize(new Rectangle(792f, 612f));
                document.NewPage();
            })
            {
                FileDownloadName = "foo.pdf"
            };

Any hints on this?

The excerpt you have included looks ok to me providing that packing is your model.

What is in your view and layout?

Have you tried with the demo project? I have updated that with some fixes as it was not building.

I should tell more information that I saved to myself (I thought that it was enough by telling the symptom -which is that instead of the PDF i'm getting a html with that string-)

This same code was working perfectly fine (locally and also deployed in ASPHostPortal), returning the PDF as expected. Until I started doing some stuff with MVC's dlls (I tried to update from MVC 4 to 5 and then I rolled back, kindof, because it rolled back to 4.0.1, or something).

After this dll mess, it continued working fine locally (it never stopped working when going through this upgrade-downgrade thing), but when I deployed and tested, I was getting this "MvcRazorToPdf.PdfActionResult" string instead of the PDF.

When I deployed I noticed that some of my MVC dlls changed (eg. system.web.webpages.dll, etc) but, as I said, this continues to work fine locally..

Now I can really ask: Any hints?

(Sorry about not giving this information before, but as I said, the symptom is very clear and made me think it was sufficient)

At the end it was totally related to that dll mess..
I restored everything as it was (all those system.web.* dlls, the web.config, the packages file, etc) and it worked again.

@germanger Thanks, weirdly I had a bit of a dll mess last night with the system.web.*. I think it was when I switched to using VS2013 community edition. I updated the project with this.