Last active
February 20, 2020 07:54
-
-
Save ekaraman89/2352adc7eeb14ec1dfc2297ac206bc6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Install-Package iTextSharp -Version 5.5.10 | |
using iTextSharp.text; | |
using iTextSharp.text.pdf; | |
using iTextSharp.text.html.simpleparser; | |
private void printHtmlToPdf(string html) | |
{ | |
StringReader sr = new StringReader(html); | |
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); | |
HTMLWorker htmlparser = new HTMLWorker(pdfDoc); | |
PdfWriter.GetInstance(pdfDoc, Response.OutputStream); | |
pdfDoc.Open(); | |
htmlparser.Parse(sr); | |
pdfDoc.Close(); | |
Response.ContentType = "application/pdf"; | |
Response.AddHeader("content-disposition", "attachment;filename=Siparis.pdf"); | |
Response.Cache.SetCacheability(HttpCacheability.NoCache); | |
Response.Write(pdfDoc); | |
Response.End(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment