I want to save aspx page as pdf file like google chrome(like picture). how can i do this ?
Asked
Active
Viewed 323 times
1 Answers
-1
Chrome uses the open source wkhtmltopdf. If you're using mvc I would recomend rotativa, which wraps the calls to wkhtmltopdf giving you
return new ActionAsPdf("Index", new { name = "Giorgio" }) { FileName = "Test.pdf" };
if you're using vanilla asp.net you can post the raw html or a link back to the server and shell out to the wkhtmltopdf command line and generate a pdf. If you're sending a link back you'll have to handle authentication as the command line app will not automatically authenticate as your user.

Miniver Cheevy
- 1,667
- 2
- 14
- 20
-
I converted only div with iTextSharp but the page is broken. Are there any solutions with iTextSharp? – Can Çalışkan Jan 01 '18 at 20:18
-
Are you loading in all the css? https://stackoverflow.com/questions/41341398/itextsharp-add-css-style-or-a-css-file-and-download-pdf-file – Miniver Cheevy Jan 01 '18 at 20:22
-
1If you want to use iText then don't use iText 5 + XMLWorker, but use iText 7 + pdfHTML instead. iTextSharp is the old name for iText .NET. – Amedee Van Gasse Jan 01 '18 at 23:52
-
I don't understand how this "answer" answers the question. – Bruno Lowagie Jan 02 '18 at 00:58
-
The image was added after I answered (or I completely missed it) – Miniver Cheevy Jan 02 '18 at 01:04
-
The image was always there. Initially as an external link, easy to overlook, and then it was made inline. – Amedee Van Gasse Jan 02 '18 at 06:59
-
@MiniverCheevy I didn't use any css when I create html page. So I should add which css file? – Can Çalışkan Jan 02 '18 at 12:14
-
@can what do thou mean by the page is broken? – Miniver Cheevy Jan 02 '18 at 14:54
-
it must be display like; https://i.hizliresim.com/GyqG02.png But it display like ; https://i.hizliresim.com/nJvyW0.png @MiniverCheevy – Can Çalışkan Jan 02 '18 at 14:59
-
that really seems css related (background colors, borders, images sizes). If you
+P the page does it look like the 2nd image? How did you apply the background color and borders? Was it inline styles? – Miniver Cheevy Jan 02 '18 at 18:05