locked
Re: Itextsharp RRS feed

  • Question

  • User-169465300 posted

    Ok but I am having some problem using Itextsharp after importing

    Imports  iTextSharp.text

    Imports  iTextSharp.text.pdf

    Imports  iTextSharp.text.html

    Imports iTextSharp.text.html.simpleparser

    As you can see the code after with selection to feed the grid is as follow

      Ds = tester.select_invoice_value(Product, description, Quantity, price, Multiplier, Divisor, Total, private_note, public_note, emails, Tags, tag, Facture_Number, Record_number, Record_number)

           

    If Ds.Tables(0).Rows.Count > 0 Then

    Response.Clear()

    Response.Buffer = True

                Response.ContentType ="application/pdf"

                Response.AddHeader("content-disposition", "attachment;filename=student.pdf")

                Response.Cache.SetCacheability(

    HttpCacheability.NoCache)

               

    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    htmlparser.Parse(sr);
    pdfDoc.Close();
    Response.Write(pdfDoc);
    Response.End();

    I just do not know which Itexsharp.dll to download and how to install it or where to place it in my project

    I just can't get Itexsharp work.

    Can you please direct me to a link with some explanation.

    Thanks.

    Saturday, November 22, 2014 8:15 PM

Answers

  • User281315223 posted

    THAT MEANS THE GREAD DID NOT FIRED.

    That shouldn't be the case.

    If you have a GridView within your <form> element (that is marked up with the runat="server" attribute) and you set the DataSource and then call the DataBind() method, that should be sufficient to update your GridView (and bind your data). Could you elaborate on exactly what you are trying to do?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 24, 2014 9:39 PM

All replies

  • User281315223 posted

    If you are wondering which particular version of the iTextSharp library to use, the easiest approach would probably be to simply download the latest package and include it in your application via NuGet. You can do this through the following steps :

    • Right-click on your Project.
    • Choose Manage NuGet Packages from the Context menu.
    • Select the Online tab on the left within the dialog box.
    • Search for "iTextSharp" in the upper right-hand corner.
    • Install the iTextSharp package that appears within the list to your project.

    This will add all of the appropriate files to use iTextSharp within your project.

    Sunday, November 23, 2014 3:38 PM
  • User-169465300 posted

    Thanks Rion,

    I am getting there but I am having some issues to pass this line. Take a look

    Dim StringWriter1 As New StringWriter()

    Dim HtmlTextWriter1 As New HtmlTextWriter(StringWriter1)

                GridView1.AllowPaging =False

                GridView1.DataSource = Ds

                GridView1.DataBind()

                GridView1.RenderControl(HtmlTextWriter1)

    The Error Message is:

    Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server. AND THE LINE  "   GridView1.RenderControl(HtmlTextWriter1)" as reference:

    My HTML for the Gridview is

    <

    asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" AutoGenerateSelectButton="True" BackColor="#FFF8F0" Font-Bold="True" Font-Names="Calibri" Font-Size="Small" Height="24px" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="9" Width="1110px">

             

    <Columns><asp:BoundField DataField="Record_number" HeaderText="LIGNE #" /><asp:BoundField DataField="Product" HeaderText="PRODUIT" />

    <asp:BoundField DataField="description" HeaderText="DESCRIPTION" ItemStyle-Width="300px" />

    <asp:BoundField DataField="Quantity" HeaderText="QUANTITE" />

    <asp:BoundField DataField="Price" HeaderText="PRIX" />

    <asp:BoundField DataField="first_int" HeaderText="MULTIPLIER" />

    <asp:BoundField DataField="second_int" HeaderText="DIVISER" />

    <asp:BoundField DataField="Total" HeaderText="TOTAL" />

             

    </Columns>

             

    <HeaderStyle BackColor="#7799FF" ForeColor="Green" />

             

    <PagerSettings FirstPageImageUrl="~/icons_dbback.gif" LastPageImageUrl="~/icons_fwd.gif" Mode="NextPreviousFirstLast" NextPageImageUrl="~/icons_dbfwd.gif" Position="TopAndBottom" PreviousPageImageUrl="~/icons_back.gif" />

             

    <PagerStyle BackColor="#00769D" BorderStyle="Groove" />

             

    <RowStyle BorderColor="#9999FF" BorderStyle="Groove" />

         

    </asp:GridView>

    Help please

    Sunday, November 23, 2014 8:40 PM
  • User281315223 posted

    As the error mentions, all of your ASPX Controls within your page must be included within a <form> element that is decorated with the runat="server" attribute as seen below :

    <form id="form1" runat="server">
         <!-- Place your GridView here -->
    </form>

    You also shouldn't need to explicitly call the RenderControl() method unless you are doing something that is out of the ordinary. Setting the DataSource and calling the DataBind() method should be sufficient.

    Monday, November 24, 2014 7:36 AM
  • User-169465300 posted

    As you mentioned all my "asp controls" are within  "<form id="form1" runat="server"> </form>"  . Without "GridView1.RenderControl(HtmlTextWriter1)" yes I got the Document but without the grid on. THAT MEANS THE GREAD DID NOT FIRED.


    Monday, November 24, 2014 6:13 PM
  • User281315223 posted

    THAT MEANS THE GREAD DID NOT FIRED.

    That shouldn't be the case.

    If you have a GridView within your <form> element (that is marked up with the runat="server" attribute) and you set the DataSource and then call the DataBind() method, that should be sufficient to update your GridView (and bind your data). Could you elaborate on exactly what you are trying to do?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 24, 2014 9:39 PM
  • User-169465300 posted

    Thanks brother I got it working.

    Tuesday, November 25, 2014 7:36 PM