issue when converting html string to pdf using evo pdf library - asp.net-mvc

I got a problem when converting html string to pdf, to be simple, I found the Kendo js/css file I referenced in my html string looks like not working at all.
Detail:
I am working on a project that converting my views(ASP MVC 4.5
) to Pdf using Evo Pdf, in my view, I have used Kendo UI controls, so I reference the Kendo css js file like below in my view file
#Scripts.Render("~/Libs/KendoUI/js/kendo.all.min.js")
<script type="text/javascript" src="#Url.Content("~/Libs/KendoUI/js/kendo.all.min.js")"></script>
When I open the view in browser, all controls works fine, but when I render the view into string, and pass it to Evo SavePdfFromHtmlStringToStream function, the pdf is generated but all the Kendo controls are missing on the pdf.
Ps, I know maybe I can use the absolute URL to convert URL to Pdf, but I am using view with model(model are posted to controller), so I don’t really want to do that.

Actually, I found the solution 2 weeks ago from Evo team, I just need set a base url in the parameters, that's all, now works fine! thanks for all!

Related

Display file in an Iframe MVC Razor

My problem here is I have been trying to display a pdf file in an Iframe.It works fine in IE but not working in chrome or firefox.However I am able to open them in a new tab.But as per my requirement I have to display it along with other form where data from pdf will be filled in the form.So I have used Iframes.Is there any other solution to display file along with form other than Iframes.what can i do with it? Below is the one which I tried.
<iframe src="file://///GSEV/PdfsFolder/#Model.FileName"></iframe>
<iframe src="#Url.Content("file://///GSEV/PdfsFolder/" + Model.FileName )"></iframe>
thanks in advance..

Getting HTML(Readable) Format from RadRichTextBox using MVC

I am building an application on MVC, where we had same application in MVVM silverlight, we had no problem in using PDF's an RadRichTextBox formats, so in MVC we are using same database same as in MVVM, and here I am having some problem as below
in sql server database we have already stored a radrichtextbox formatted data, and using MVC I am trying to get that data and put it back to PDF(which is working fine in MVVM), and I am able to put it on PDF without any problem, but the format which get it on PDF is not in proper order or its not readable, below I am providing example of format what I have on sql server and what format I am expecting it from there
My question
Is there any way we could use that radrichtextbox format to convert it into HTML format so that I can use it on PDF
since I am using MVC is there any dll, so that i can implement to get right format
NOTE
I already searched in stack forum with no help, and I even contacted Telerik people regarding this all they were able to help me out is for silverlight
and This link from telerik rich-editor will help me to get it into right format which I need but finding hard time to implement
So if there any one could able to help me or even guide me in this would be much helpful for me, Thanks
UNFORMATTED DATA WHICH I GET FROM SQL SERVER
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled</title><style type=\"text/css\">\r\n.s_D8D99854 { font-family: 'Verdana';font-style: Normal; } \r\n</style></head><body><p ><span class=\"s_D8D99854\"> hello</span></p></body></html>
AND THIS IS THE FORMAT I SHOULD GET FROM ABOVE
I believe that you can easily strip the content by yourself using the server-side String.Replace method by converting all \" instances to "
If the PDF convertor does not understand the meta tags, the HTML, HEAD and BODY tags then strip them too using regular expressions.

How do I return MVC File ActionResult of PDF over jQuery modal dialog

Note: I am not wanting to display the PDF inline with the modal. Rather, I am looking to have the browser acknowledge the file and allow the user to save or open it.
I have a jQueryUI modal dialog in MVC 4. The dialog IS modal. The content of the dialog is from a Partial Views which works fine. I have only one button on the dialog itself and have successfully gotten all the JavaScript to deal with client side data entry checking.
What is giving me a headache is that I have one button embedded in the Partial View that is to display a PDF file. I can successfully call a JavaScript function that calls the controller that gets the file from another server. I can even get the file converted to a byte array and the last line is
return File(contents, "application/pdf", "PropsedChanges.pdf");
However it will not open as I suspect that the modal dialog is preventing it.
I have done something similar outside of the model dialog and it gives me the save/open option at the bottom of the screen for IE or in the correct manner in other browsers.
Is there a way to display the PDF in a registered PDF viewer on the client's PC/Device outside of the browser needing to ask if they want to save or open it? Which, as I suspect, is not happening due to the modal dialog.
Help is greatly appreciated.
public ActionResult GetPdf(Model modelo)
{
return File(Pdf bytes[], "application/pdf");
}
Try using a new window to open your PDF. Like target="_new" or "blank".
If you are using Asp.net 5, install MvcPdfActionResult via nuget
PM> Install-Package MvcPdfActionResult
Simply use return type as PdfActionResult in the controller will output PDF document instead of HTML. This converts HTML to PDF using the iTextXmlWorker Library.
...
return PdfActionResult(model);
}
Generates pdf documents from your razor views within an asp.net 5 MVC project. https://www.nuget.org/packages/MvcPdfActionResult/

Display file (PDF/TXT) on form brought from Database in MVC ASP.NET

I want to display file on my form using MVC.
I am bringing a Byte[] array data from the Database, and using FileContentResult I am converting it into a file.I want to now display this file on my page for viewing . How can it be acheived. What code to write in my View for the same.
Assuming you're using Razor, rendering a text file can be done as simple as:
<div>
#(new System.IO.StreamReader("myFile.txt")).ReadToEnd()
</div>
For PDF files, you'll have to find a third-party component to convert to HTML.
You probably don't want to use FileContentResult, that is something generally used for providing the raw file.
In theory though there is nothing different in using any other url
<img src="#Html.ActionLink("View","Image",{id = Model.key})" />
Or you can provide that link in a pdf reference, or as a stylesheet etc.

Using JQuery with ASP.NET MVC Framework

I have searched the forum, and google for this topic. Most of the articles are talking about using JSON to call the controller/action on the server and do ajax effect on the result.
I am trying to use some very basic JQuery features, like the JQuery UI/Tabs, and JQuery UI/Block for a dialog window. I cannot get these simple samples to work in my MVC project. Any ideas how I should modify these samples? I only need these basic feature now and I can go from here.
Thanks!
Actually I just got it working. The problem is that I need to modify the path to an absolute path to the view page because the relative path doesn't work with the MVC routes {controller}/{action}/{id}.
Thanks!
For info, re the relative path issue - I discussed this here (the same concept applies to any page, not just master pages). The approach I used is like so:
1: declare an extension method for adding scripts:
public static string Script(this HtmlHelper html, string path)
{
var filePath = VirtualPathUtility.ToAbsolute(path);
return "<script type=\"text/javascript\" src=\"" + filePath + "\"></script>";
}
2: when needed (for example in the <head>...</head>) use this method:
<%=Html.Script("~/Scripts/jquery-1.2.6.js")%>
The advantage of this is that it will work even if the web app is hosted in a virtual directory (i.e. you can't use "/Scripts" because you aren't necessarily at the site root) - yet it is a lot clearer (and less messy) than the full script with munged src, i.e.
<script ... src="<%=Url.Foo(...)%>"></script>
I just implemented the jquery autocomplete textbox in one of my asp.net project. I only had to import the js file and drop some code into my aspx page. Could you be more detailled about what sample you are trying to run?
This is quick response!!
I am trying to run this "Simple Tabs" on this page:
http://stilbuero.de/jquery/tabs/
I think it is the same with this one: http://docs.jquery.com/UI/Tabs
I just copied and pasted the whole thing into my MVC view page, with corrected path to the jquery.js and .css files, but the content in the tabs all show up together (two of them are supposed to be hidden). My understanding is that this simple jquery plugin just show and hide content.
I had the exact same problem with the jquery thickbox plugin, that the item marked as "hidden" (the dialog box) will always show up in my MVC view page.
I can understand some of the MVC+Jquery+json articles, but I don't understand why the hide/show doesn't work.
Thanks!
I just made a walkthrough on how to do this:
http://blogs.msdn.com/joecar/archive/2009/01/08/autocomplete-with-asp-net-mvc-and-jquery.aspx

Resources