1

I am trying to check out MvcRazorToPdf. I'm installing it from Nuget Manager. When I attempt to build the project I get this error message:

Error 5 Assembly 'MvcRazorToPdf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'itextsharp, Version=5.5.3.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' which has a higher version than referenced assembly 'itextsharp, Version=5.5.0.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' d:\PROJECTS\Crowdiet\packages\MvcRazorToPdf.1.0.2\lib\40\MvcRazorToPdf.dll Crowdiet

In order to solve it I installed the latest version of iTextSharp from Nuget. Version 5.5.7 Now I'm building and so it runs.

However, when trying to execute MvcRazorToPdf code I get the following error message:

Could not load file or assembly 'itextsharp.xmlworker, Version=5.5.3.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'itextsharp.xmlworker, Version=5.5.3.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Any ideas how to deal with this? Thanks.

dsb
  • 2,347
  • 5
  • 26
  • 43
  • I had issues trying to use itextsharp when generating pdfs for my mvc application. I used Rotativa to produce my pdfs, it's very easy to setup and implement. Have you tried it? – Scanner Nov 17 '15 at 15:16
  • @Scanner Thank you. I didn't check it out. I'll take a look at it right now. – dsb Nov 17 '15 at 15:45
  • checkout this link for gudiance https://github.com/webgio/Rotativa if you need any help just let me know – Scanner Nov 17 '15 at 15:53
  • @Scanner Man, that worked beautifully. However, at some point my firewall asked me for a permission for some wkhtml...something. Will it not be a problem to put it on Azure website? – dsb Nov 17 '15 at 17:05
  • Knew it would buddy;). Are you using this for work purposes? – Scanner Nov 17 '15 at 17:10
  • @Scanner Yep, for work purpose. Anything in particular I should do? BTW, up until here everything works wonderfully: var file = File(binary, "application/pdf"); Do you have any idea how do I save the result to a file? – dsb Nov 17 '15 at 17:31
  • for wkhtml I recently had to update 3 files for that. I'll try and find the link for that and send you it. For the firewall you might need to contact your service desk in work or your system administrator as they need to grant you access to allow it through the firewall. I'm not sure about azure as my web app isn't hosted on azure. I believe there is a way to save it to file, I'm at home now and my stuff is all in work, is it ok to send you it tomorrow? – Scanner Nov 17 '15 at 17:52
  • I found these links which should help you to learn how to save the PDF http://stackoverflow.com/questions/26608729/how-to-save-rotativa-pdf-on-server http://stackoverflow.com/questions/32181904/save-pdf-file-as-a-byte-array-or-stream-using-rotativa https://github.com/webgio/Rotativa/issues/19 http://www.codeproject.com/Tips/818197/Generate-PDF-in-ASP-NET-MVC-Using-Rotativa – Scanner Nov 17 '15 at 18:07
  • @Scanner man, you are the best! I've been spending two days on this. Thank you so much. – dsb Nov 17 '15 at 18:41
  • no worries dude happy to help!! As I said I had a few problems myself until I found Rotativa. Any other issues just let me know!! – Scanner Nov 17 '15 at 18:59
  • @dsb did you get this to work? I have found I had to install the version 5.5.3 (not the latest 5.5.7) of both itextsharp and the itextsharp xml worker for it to work – Pete Nov 27 '15 at 13:35
  • @Pete, yep. I contacted the writer and that's what he told me to do. Anyway, eventually I used Rotativa as Scanner's suggested. Worked easily for me. – dsb Nov 30 '15 at 10:30

1 Answers1

0

DSB I've written this as theres too much to place in a comment.

This link should help address your azure query SO.

In regards to what I had said about updating your wkhtml files you need to click this link wkhtml download (this is a link for the site wkhtml page) as this will provide you with the 3 updated files you need for rotativa. There's 2 things that you can do when the download has finished in order to get these new files into your solution. This download will save a setup program to your computer which contains the 3 files. When you are saving the files make a note of where you are saving them to.

  1. Download 7 zip found at 7zip or any file extracting tool if you don't already have one. Right click on your download and use the extraction tool to extract and save the 3 updated files.

    1. If you can't download or don't have an extraction tool then run the setup of the downloaded file. This should save into your program files in your standard drive. Navigate through program files to the wkhtmltopdf folder, click on it, then click the bin folder and inside this you'll find the 3 updated wkhtml files.

When you've got these three files add these to your existing rotativa folder inside your solution. Do a rebuild of the soultion if necessary just to update it. Hope this helps!!

Community
  • 1
  • 1
Scanner
  • 597
  • 1
  • 9
  • 19