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.
125 stars 105 forks source link

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

Closed germanger closed 9 years ago

germanger commented 9 years ago

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?

andyhutch77 commented 9 years ago

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.

germanger commented 9 years ago

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)

germanger commented 9 years ago

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.

andyhutch77 commented 9 years ago

@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.