Exporting MVC3 Print view to PDF - asp.net-mvc-3

Is it possible with MVC3 (using 3rd party plugins if necessary) to generate a PDF dynamically using the print view of a page? As in, the layout you see if you print or print preview the view.
I know that iText(sharp) can create a PDF out of a normal view of a page but I need to create the print view PDF (via the controller preferably) so that it can be emailed.
I had Crystal Reports in place previously but have scrapped it in favor of HTML reports.

I solved my problem by implementing Rotativa (available from NuGet). It's much simpler and more effective than other converters around (gets a bit tricky with custom authentication though).

Related

Can I add a partial view to an existing MVC5 project?

I need to implement a Telerik control into an existing page of a MVC5 project.
The problem is that I don't own the source code of the project (it's an off the shelf framework) so when I open it in VS there is not the model and controller files (only the shared view) so I cannot modify it accordingly to my needs. The shared view is a cshtml file with pure HTML stuffed with a bunch of HTML helpers and a couple Razor blocks.
Since I am pretty new in MVC I would like to know if it's possible that I create a custom "partial view" from scratch inside this project and invoke it from the shared view.
I am asking the feasibility of it before I waste a lot of time chasing my own tail on something that cannot be done... :/

Create PDF form-fillable fields from Visual studio

A bit of a Visual Studio 2010 newbie here, but I have developed a modest working knowledge of how to create report forms linked to a database, but I have come across something that I have yet to face.
I have created a report that has three tables on it. Tables 1 (equipment specs) and 2 (operation schedule) are linked to my database. Table 3 is a table (equipment performance audit) that will need to be populated by the people out in the field. They will have to populate these fields in a PDF editor (Adobe) while they are out in the field and simply save them to PDF file. I do not believe there is a plan to have them to be imported back into a database table (which I think we should, but I don't help make those decisions...yet), so we don't need to worry about that.
The problem that I am facing is that I have no idea how to generate the fillable (i.e. text box?) fields for the PDF in Visual Studio, I tried inserting text boxes, but that didn't work...
Any help would be greatly appreciated. Thank you!
Have a look at the ITextSharp library. It will allow you to create PDF files on the fly. I'm pretty sure that it is also able to create PDF forms as well.
ITextSharp is a port of the JAVA based IText PDF library. so most of the conceptual information that applies to IText will also apply to ITextsharp
Some code examples to help:
- iTextSharp — few C# examples.
- Generating PDF using ItextSharp with Footer in C#
- Create PDFs in ASP.NET- getting started with iTextSharp
- IText In Action book samples
- Answer to Fill PDF Form with Itextsharp

Render DevExpress XtraReport template as HTML

We are using DevExpress DX.10.2. Our client has asked to be able to view the XtraReport templates (not the report itself, just the template) within an MVC 3 application that we maintain for them.
My first thought was that I'd have to fake the data to look like the "template" and show the actual reports. However, I noticed in Visual Studio that the XtraReport designer has an "HTML View" option that renders the template in HTML.
I would think that if DevExpress is able to render the template as HTML in the designer then it's likely that there's a way to extract that HTML to render on a view. Is there a way to extract HTML from an XtraReport template?
Thanks!
Stumbled across the solution. Had to add a reference to DevExpress.XtraReports.Web and then the following line writes the report HTML to the response stream:
XtraReport1 report = new XtraReport1();
DevExpress.XtraReports.Web.ReportViewer.WriteHtmlTo(System.Web.HttpContext.Current.Response, report);

View PDF as a SlideShow?

I'm looking for an answer, if there is somehow possible to view a PDF file (ASP.NET MVC 3 project) in other way like a standard in the adobe plugin. My client wants to:
show the PDF file like a slide show (or navigate horizontally through the pages)
protect the PDF file from being downloaded
so, maybe there is a JavaScript/jQuery control to change the presentation of the PDF or maybe some other way ? Is it even possible ? Any ideas ?
Google has an open PDF viewer. Trying it out:
https://docs.google.com/viewer?url=www.graphpad.com/manuals/prism4/StatisticsGuide.pdf

Adding HTML5 markup to a MVC3 site

I have already created a MVC3 site but when I did I didn't select the HTML5 markup option. I would like to add some 'safe' HTML5 markup into the MVC3 site unless there is a way to convert the project to use HTML as if I had selected it from the start (is that possible?).
Would I be safe changing the _layout.cshtml to use HTML5 markup such as nav? How do I use my current CSS style sheet to make sure it positions it correctly (is it as simple as adding the class)?
I understand you can select the 'Target Schema For Validation' option to HTML5. Is that mainly for intellisense? Is this one of the primary bi-products of selecting the HTML5 option at project creation time or are there many more impacts other then this target schema and the _layout page?
Thanks much in advance!
There is no magic to the HTML5 support in MVC3. The checkbox in the project template dialog simply creates a different _layout file with <nav> instead of <div>, a reference to modernizr.js, etc. You're free to change the markup of the _layout file to whatever you like.
The schema validation dropdown simply governs what code completion options you get from Intellisense, and what warnings you get when adding markup that does not conform to the schema. But again, if the HTML5 standard gets updated with new tag next week, and Microsoft fails to update Visual Studio, you're free to add markup that doesn't conform to the VS schema.

Resources