如何使用asp.net中的itextsharp将pdf存储到一个文件夹中 [英] How to store pdf into one folder using itextsharp in asp.net

查看:76
本文介绍了如何使用asp.net中的itextsharp将pdf存储到一个文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码在asp.net中使用itextsharp创建pdf。它的工作完全正常..



  string  attachment =   attachment; filename = +   abc +  。pdf; 
Response.ClearContent();
Response.AddHeader( content-disposition,附件);
Response.ContentType = application / pdf;
StringWriter s_tw = new StringWriter();
HtmlTextWriter h_textw = new HtmlTextWriter(s_tw);
h_textw.AddStyleAttribute( font-size 8pt);
h_textw.AddStyleAttribute( color 黑色);
divApplicantData.RenderControl(h_textw);
文档doc = new Document();
doc = new 文档(PageSize.A3, 5 5 15 5 );
FontFactory.GetFont( Verdana 80 ,iTextSharp.text.BaseColor.RED);
PdfWriter.GetInstance(doc,Response.OutputStream);
doc.Open();
StringReader s_tr = new StringReader(s_tw.ToString());
HTMLWorker html_worker = new HTMLWorker(doc);
html_worker.Parse(s_tr);
doc.Close();
Response.Write(doc);
Response.End();



我们如何给出特定的文件夹路径,以便将pdf存储到该特定文件夹。?<?div =h2_lin>解决方案

请参阅..

http://stackoverflow.com/questions/16889741/specify-the-location-to-save-the-pdf-file-asp-net [< a href =http://stackoverflow.com/questions/16889741/specify-the-location-to-save-the-pdf-file-asp-nettarget =_ blanktitle =New Window> ^ ]

http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp [ ^ ]


I am using following code to create pdf using itextsharp in asp.net. Its working completely fine..

string attachment = "attachment; filename=" + "abc" + ".pdf";
                    Response.ClearContent();
                    Response.AddHeader("content-disposition", attachment);
                    Response.ContentType = "application/pdf";
                    StringWriter s_tw = new StringWriter();
                    HtmlTextWriter h_textw = new HtmlTextWriter(s_tw);
                    h_textw.AddStyleAttribute("font-size", "8pt");
                    h_textw.AddStyleAttribute("color", "Black");
                    divApplicantData.RenderControl(h_textw);
                    Document doc = new Document();
                    doc = new Document(PageSize.A3,5,5,15,5);
                    FontFactory.GetFont("Verdana", 80, iTextSharp.text.BaseColor.RED);
                    PdfWriter.GetInstance(doc, Response.OutputStream);
                    doc.Open();
                    StringReader s_tr = new StringReader(s_tw.ToString());
                    HTMLWorker html_worker = new HTMLWorker(doc);
                    html_worker.Parse(s_tr);
                    doc.Close();
                    Response.Write(doc);
                    Response.End();


How can we give particular folder path so that it will store pdf's to that particular folder.????

解决方案

See..
http://stackoverflow.com/questions/16889741/specify-the-location-to-save-the-pdf-file-asp-net[^]
http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp[^]


这篇关于如何使用asp.net中的itextsharp将pdf存储到一个文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆