使用c#使用itextsharp创建pdf时添加css

时间:2013-08-02 12:44:31

标签: c# asp.net itextsharp

我使用以下代码,创建一个pdf,它工作正常。我想将pdss添加到pdf中。我该怎么办?

Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=Clinic-Locator-Information.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            dl_ClinicList.RenderControl(hw);
            StringReader sr = new StringReader(sw.ToString());
            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.Write(pdfDoc);
            Response.End();  

0 个答案:

没有答案