locked
Converting Gridview to PDF RRS feed

  • Question

  • User1104400338 posted

    Hello. I am trying to convert a gridview in ms visual studio to PDF but not being successful. This what I have in my visual basic code behind:

    Imports iTextSharp.text

    Imports iTextSharp.text.pdf

    Imports iTextSharp.text.html

    Imports iTextSharp.text.html.simpleparser

     Partial Class Default2

        Inherits System.Web.UI.Page

        Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)

         End Sub

     Protected Sub btnExportPDF_Click(ByVal sender As Object,

    ByVal e As EventArgs)

     Response.ContentType = "application/pdf"

     Response.AddHeader("content-disposition",

     "attachment;filename=GridViewExport.pdf")

     Response.Cache.SetCacheability(HttpCacheability.NoCache)

     Dim sw As New StringWriter()

     Dim hw As New HtmlTextWriter(sw)

     GridView1.AllowPaging = False

     GridView1.DataBind()

     GridView1.RenderControl(hw)

     Dim sr As New StringReader(sw.ToString())

     Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F)

     Dim htmlparser As New HTMLWorker(pdfDoc)

     PdfWriter.GetInstance(pdfDoc, Response.OutputStream)

     pdfDoc.Open()

     htmlparser.Parse(sr)

     pdfDoc.Close()

     Response.Write(pdfDoc)

     Response.End()

    End Sub

    End Class

    The question I have is this: Are Imports iTextSharp.text, Imports iTextSharp.text.pdf, Imports iTextSharp.text.html, and Imports iTextSharp.text.html.simpleparser files that I need to download from somewhere, and where do find them to download? (FOR FREE OF COURSE)

    Thursday, January 5, 2012 3:18 PM

Answers

  • User-837620913 posted

    It depends on how you are using iTextSharp.  iText is open source released under the Affero General Public License v3.  What does that mean?

    In accordance with Section 7(b) of the GNU Affero General Public License, you must retain the producer line in every PDF that is created or manipulated using iText.
    You can be released from the requirements of the license by purchasing a commercial license. Buying such a license is mandatory as soon as you develop commercial activities involving the iText software without disclosing the source code of your own applications. These activities include: offering paid services to customers as an ASP, serving PDFs on the fly in a web application, shipping iText with a closed source product.

    More about the license here:  http://itextpdf.com/terms-of-use/agpl.php

    If you are using it in a non-commercial fashion, then go get the iTextSharp libraries here:  http://itextpdf.com/download.php

    If you are using it in a commercial fashion, you either need to post ALL of your site's source code or purchase a license.

    The standard disclaimers apply - I am not a lawyer so I cannot offer you legal advice.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 6, 2012 7:07 AM

All replies

  • User-837620913 posted

    It depends on how you are using iTextSharp.  iText is open source released under the Affero General Public License v3.  What does that mean?

    In accordance with Section 7(b) of the GNU Affero General Public License, you must retain the producer line in every PDF that is created or manipulated using iText.
    You can be released from the requirements of the license by purchasing a commercial license. Buying such a license is mandatory as soon as you develop commercial activities involving the iText software without disclosing the source code of your own applications. These activities include: offering paid services to customers as an ASP, serving PDFs on the fly in a web application, shipping iText with a closed source product.

    More about the license here:  http://itextpdf.com/terms-of-use/agpl.php

    If you are using it in a non-commercial fashion, then go get the iTextSharp libraries here:  http://itextpdf.com/download.php

    If you are using it in a commercial fashion, you either need to post ALL of your site's source code or purchase a license.

    The standard disclaimers apply - I am not a lawyer so I cannot offer you legal advice.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 6, 2012 7:07 AM
  • User1104400338 posted

    Thanks. Sorry for getting back to you late. But I already did it. THANKS

    Sunday, January 8, 2012 3:26 PM