2011-07-15 59 views
-1

可能重复:
Directly convert .aspx to .pdf如何将aspx页面转换为pdf文件?

我已经作出一个aspx页面,并通过图表控制asp.net的产生在其上的图表。 但我无法生成此生成的图表为PDF文档。我想使我的aspx页面成为pdf文档。预先感谢您的支持。

+0

您的网页是否包含闪存(用于图表)? – Devjosh

+1

尝试在stackoverflow上搜索'aspx pdf',每周至少询问一次这个问题。 –

+0

你想为自己做这个,还是你想让你的访客能够做到这一点? –

回答

0

当您尝试aspx页面转换成PDF格式,这意味着inturn你要呈现的HTML转换所以这里PDF是一个很好的链接,可以帮助你,尽管我没有尝试过,但看起来很有希望

It's Here

注:我假设您的网页不包含任何Flash图表。

-1

使用itextsharp.dll我确定你可以使用这个dll 很容易实现你的pdf页面。

using iTextSharp.text; 
using iTextSharp.text.pdf; 
using iTextSharp.text.html; 
using iTextSharp.text.html.simpleparser; 

//这将是按钮的点击

string attachment = "attachment; filename=" + filename+ ".pdf"; 
    Response.ClearContent(); 
    Response.AddHeader("content-disposition", attachment); 
    Response.ContentType = "application/pdf"; 
    StringWriter stw = new StringWriter(); 
    HtmlTextWriter htextw = new HtmlTextWriter(stw); 
    htextw.AddStyleAttribute("font-size", "7pt"); 
    htextw.AddStyleAttribute("color", "Black"); 

    Panel_Name.RenderControl(htextw);//Name of the Panel 
    Document document = new Document(); 
    document = new Document(PageSize.A4, 5, 5, 15, 5); 
    FontFactory.GetFont("Arial", 50, iTextSharp.text.BaseColor.BLUE); 
    PdfWriter.GetInstance(document, Response.OutputStream); 
    document.Open(); 

    StringReader str = new StringReader(stw.ToString()); 
    HTMLWorker htmlworker = new HTMLWorker(document); 
    htmlworker.Parse(str); 

    document.Close(); 
    Response.Write(document); 

粘贴此页上的某些地方

public override void VerifyRenderingInServerForm(Control control) 
{ 


} 
+0

我曾尝试使用itextshart.dll,但它给了我在线上使用的非法字符的错误 - obj.Parse(se); – Rushi

+0

粘贴一些代码,以便我可以检查 –

+0

检查我编辑的文章 –