Rotativa | Make Pdf from Asp.Net MVC | Model View Controller library
kandi X-RAY | Rotativa Summary
kandi X-RAY | Rotativa Summary
Rotativa, /rota'tiva/. Make Pdf from Asp.Net MVC. Available on Nuget https://www.nuget.org/packages/Rotativa
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Rotativa
Rotativa Key Features
Rotativa Examples and Code Snippets
Community Discussions
Trending Discussions on Rotativa
QUESTION
I have an MVC page that use a combination of Razor and C# code to render the html output. The page renders fine in the browser. However, in my browser when I use Rotativa to generate a PDF to print the page I get what seems to be JSON output instead of the formatted PDF.
I am using Visual Studio 2019 with .NET 5.0 and Rotativa 1.7.3.
I know I could try other HTML-to-PDF but Rotativa seems to be the best open source alternative.
Can someone please tell me what I am doing wrong so I can get the output to render as a PDF?
I am including excerpts of my code rendering the page, the Rotativa code and the "PDF" output.
...ANSWER
Answered 2021-Dec-13 at 22:58Xudong, you were right about the response header being wrong. I downloaded a .net project which worked. I then did some more online searches and realized that I was using .net Core so I needed to download the .net Core version of Rotativa not the .net 4.6 version. With some help from the link, PDFCore , I was able to get my program to generate PDFs.
QUESTION
I'm struggling very hard to be able to print a simple certificate template, my current problems are:
I need to set two images for background, front page and backpage. Currently I set them up using some css positioning through tags.
When I set all the layout, they are fine in the HTML view, however, once I try yo print from browser, or from a custom plugin (rotativa wkhtmlpdf), the layout get messed up and all formatting is gone.
Below is the code: PS. @img_frente and @img_verso are base64 strings for the images as backgrounds.
...ANSWER
Answered 2021-Apr-08 at 13:15I've come to a solution, treating div structure as parent/child with a master container on each block of the certificate, then aligned them with relative/absolute positioning. Full code below:
PS. I removed useless scripts and the viewbags at src in img tags and vars are just base64 strings. I hope this can help people out!
QUESTION
I am using a digital ocean droplet using Ubuntu 18.04 LTS and deployed my ASP.NET Core 5.0 MVC project on it and everything works great. I was trying to install rotativa on it to print pdf documents but I cannot make this work.
I followed these steps: https://blog.elmah.io/generate-a-pdf-from-asp-net-core-for-free/
But I am getting this error when trying to print the pdf:
Exception: QPainter::begin(): Returned false Exit with code 1, due to unknown error.
I have this in my Startup.cs:
...ANSWER
Answered 2021-Jan-04 at 19:19It's an issue with .NET 5. Looks related to the invoking Wkhtmltopdf.
QUESTION
I am currently implementing IdentityServer4 with my microservices to authenticate users. My client application is a MVC project. While I run the project client application return an error as following,
Sorry, there was an error : invalid_scope Invalid scope Request Id: 8000008d-0000-f700-b63f-84710c7967bb
When I removed apiscopes from config file application works fine but then I didn't get any user claims in my authorization handler.
Here's my code
Config.cs
...ANSWER
Answered 2021-Feb-11 at 07:43You should change the grant type to Code and also enable PKCE, because that is best practice to use when you use the authorization code flow.
QUESTION
I want to display dynamic header in a cshtml. When i try to pass it using CustomSwitches i get an error like QPaintDevice: Cannot destroy paint device that is being paintedpure virtual method called terminate called without an active exception.
Calling Rotativa component(it's in a class library) from mvc Controller to print the dynamic view without header works correctly but not with the header. Is there anyway to solve this problem?
Thank you for your answers.
Edit: Example using Rotativa
string header = $"/Header.cshtml";
var customSwitches = string.Format("--header-html "{0}" " + "--header-spacing "0" ", header);
...ANSWER
Answered 2020-Dec-10 at 07:34customSwitches
may not find /header.cshml. You need to give the correct path.
QUESTION
I have to send mails in my background application, for this I use Hangfire, but I have to attach a document to each mail with its recipient, the information of the document to be attached is in a table that I convert with rotativa.
My concern is when I want to convert the document into byte[]
I always get that the HttpContext
is null
, obviously because there is no HTTP request which triggers the action while everything is in the background.
Here is my actual code:
...ANSWER
Answered 2020-Oct-27 at 22:29It looks like an issue in Rotativa lib that it has to take a controller context, github.com/webgio/Rotativa/pull/88
And you won't be able to pass the context to hangfire background process as you listed.
A work around (incase the file is not too big) might be that your hangfire process call a URL on your website which do the email sending code instead of doing the Rotativa and email sending in the hangfire background process.
QUESTION
I'm new to ASP.NET MVC and I am trying to print the filtered records between two dates to a PDF. I'm using ROTATIVA to generate the PDF, the problem is that the PDF is generated correctly but with all the records and not only with the result of the record filter by the two dates.
Code for the Controller:
...ANSWER
Answered 2020-Nov-03 at 23:28You're calling the SalesToPdf
action with no parameter which means it will always match the unfiltered list. You can pass parameters into the ActionAsPdf
overloads as shown in the documentation here
In your case this would probably require some kind of separate action for the filtered list like this:
QUESTION
I want to send a (view page) pdf sending by email.but when I trying to add an attachment, I found an error below "Add". for that I can't successfully sending mail with attaching my view pdf. Here is my code:
...ANSWER
Answered 2020-Oct-27 at 08:25Attachments is a MimeMessage property that has no such method Add, so here comes the error. To add the attachments you should create a BodyBuilder object before, with this class you will be able to add new attachments (each one of them as byte array), usign Attachments Property and its Add method, but always related to BodyBuilder, not to MimeMessage.
Please, take a look to the answer given here, as I guess is what you are looking for: .net Core Mailkit send attachement from array
Or check another example here: https://www.taithienbo.com/send-email-with-attachments-using-mailkit-for-net-core/
In addition, you could get Rotativa PDF as byte array usign this code:
QUESTION
I am generating a pdf, and my employer asked me to add a footer to every single page in the pdf. The pdf gets generated with Rotativa, with a html page that turns into a pdf.
My only problem is, how am i gonna do this. I thought about some ideas, plain css code, although there are more then enough options, none of them really worked out for me. Especially because i can have 1 page, or i can have 10, depends on the amount of information that has to be put onto it.
So the footer has to be responsive to the amount of pages that will be generated.
Does anyone have any ideas for me? I want to get this worked out really bad, but i just have no clue how to.
Greetings Lorenzo Otto
...ANSWER
Answered 2020-Oct-19 at 07:42If I have not misunderstood your question, you could simply use an HTML page as a footer, to display the page footer, involving some javascript to display the current page and total number of pages. I'am actually using this approach for several web applications using Rotativa that generate PDF files based on MVC views with dynamic content.
Supposing we create a Footer.html (use the name you prefer here), this could be the HTML file for the PDF footer, including javascript code to generate page number info:
QUESTION
i work with ASP.NET MVC and i try to use rotativa for build a pdf by model. The problem is that in this context i operate in a model (i can't move the code in controller), and i write a procedure into a controller for build pdf. Like this
...ANSWER
Answered 2020-Aug-24 at 10:53If you take a look at ControllerContext class documentation, it is expected to has HTTP request information. As you have instantiated this controller, there is no related HTTP request, so the context has no data.
Maybe you could try building your own HTTP data on this ControllerContext class. Please, try using this code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Rotativa
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page