2011-09-22 8 views
0

私はASP.Netアプリケーションを開発しました。私はいくつかのエントリを持つWebフォームを開発しました。今、私はこのフォームをPDFファイルに変換したいのですが、可能でしょうか?ASP.Net WebからPDFを作成する方法

いいえ、無料のライブラリですか?

答えて

0

ITextSharpなどのフリーライブラリを使用することも、より複雑なシナリオでは、サーバーバージョンのTxtControlを使用してWebサイトからドキュメントを生成することもできます。

TxtControlもあなたが便利Ghostscriptのライブラリを見つけることがありますitextsharpまたはpdf sharp

+0

iTextSharp( iTextも)は、オープンソースソフトウェアのみ*無料です。他の用途では、商用ライセンスを購入する必要があります。 – Bobrovsky

2

を文書を作成するためのオンデマンドサービスを提供していますhttp://www.ghostscript.com/

+0

wkhtmltopdfは良いオープンソースの無料オプションです。解決策を探して、wkhtmltopdfをサービスとして公開しました。なぜなら、複数のクライアントにサービスを提供する必要があったからです。その後、APIをhttp://www.html2pdfrocket.comで一般公開しました。使用する場合は無料です。 – eagle779

0

を使用することができますPDFファイルを作成するには...

0
 Document doc = new Document(PageSize.A4); 
    // Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); 
    Response.ContentType = "application/pdf"; 
    Response.AddHeader("content-disposition", "attachment;filename=hello.pdf"); 
    Response.Cache.SetCacheability(HttpCacheability.NoCache); 

    PdfWriter.GetInstance(doc, Response.OutputStream); 
    string imagepath = Server.MapPath("IMG"); 
    doc.Open(); 

    doc.Add(new Paragraph()); 
    Image gif = Image.GetInstance(imagepath + "/asd.jpg"); 
    doc.Add(gif); 

    PdfPTable table1 = new PdfPTable(2); 

    table1.WidthPercentage = 90; 

    PdfPCell cell11 = new PdfPCell(); 

    cell11.AddElement(new Paragraph("Receipt ID : " + 124325)); 

    cell11.AddElement(new Paragraph("Date : " + "25-Feb-2013")); 

    cell11.AddElement(new Paragraph("Photo Status : " + "No")); 

    cell11.VerticalAlignment = Element.ALIGN_LEFT; 

    PdfPCell cell12 = new PdfPCell(); 

    cell12.AddElement(new Paragraph("Transaction ID : " + 4544)); 

    cell12.AddElement(new Paragraph("Expected Date Of Delivery : " + "25-Feb-2013")); 

    cell12.VerticalAlignment = Element.ALIGN_RIGHT; 

    table1.AddCell(cell11); 

    table1.AddCell(cell12); 

    PdfPTable table2 = new PdfPTable(3); 



    //One row added 

    PdfPCell cell21 = new PdfPCell(); 

    cell21.AddElement(new Paragraph("Photo Type")); 

    PdfPCell cell22 = new PdfPCell(); 

    cell22.AddElement(new Paragraph("No. of Copies")); 

    PdfPCell cell23 = new PdfPCell(); 

    cell23.AddElement(new Paragraph("Amount")); 

    table2.AddCell(cell21); 

    table2.AddCell(cell22); 

    table2.AddCell(cell23); 



    //New Row Added 

    PdfPCell cell31 = new PdfPCell(); 

    cell31.AddElement(new Paragraph("type")); 

    cell31.FixedHeight = 300.0f; 

    PdfPCell cell32 = new PdfPCell(); 

    cell32.AddElement(new Paragraph(5)); 

    cell32.FixedHeight = 300.0f; 

    PdfPCell cell33 = new PdfPCell(); 

    cell33.AddElement(new Paragraph("20.00 * noOfCopy = " + (20 * Convert.ToInt32(5)) + ".00")); 

    cell33.FixedHeight = 300.0f; 



    table2.AddCell(cell31); 

    table2.AddCell(cell32); 

    table2.AddCell(cell33); 



    PdfPCell cell2A = new PdfPCell(table2); 

    cell2A.Colspan = 2; 

    table1.AddCell(cell2A); 

    PdfPCell cell41 = new PdfPCell(); 

    cell41.AddElement(new Paragraph("Name : " + "fdfgdg")); 

    cell41.AddElement(new Paragraph("Advance : " + "245")); 

    cell11.VerticalAlignment = Element.ALIGN_LEFT; 

    PdfPCell cell42 = new PdfPCell(); 

    cell42.AddElement(new Paragraph("Customer ID : " + 34345)); 

    cell42.AddElement(new Paragraph("Balance : " + 20545)); 

    cell42.VerticalAlignment = Element.ALIGN_RIGHT; 

    table1.AddCell(cell41); 

    table1.AddCell(cell42); 
    doc.Add(table1); 

    doc.Close(); 


    //pdfDoc.Open(); 
    //htmlparser.Parse(sr); 
    //pdfDoc.Close(); 
    Response.Write(doc); 
    Response.End();