|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Its inserting a page breakHi
i am trying to print a pdf from a table, but the file have a page break after the tr, how can i solve it? here a example of the file http://lfvo.byethost31.com/example.pdf the the table i am trying to convert <table width="100%" border="0" id="newsTable" runat="server"> <tr> <td> <asp:Label ID="lblTitulo" CssClass="PageTitles" runat="server" Text=""></asp:Label> <div style="padding: 4px 0px 0px 5px"> <asp:Label ID="lblAutor" runat="server"></asp:Label></div> <div style="padding: 0px 0px 0px 5px"> <asp:Label ID="lblData" runat="server"></asp:Label></div> </td> </tr> <tr> <td style="padding-top: 2px"> <hr /> </td> </tr> <tr> <td style="padding-top: 4px"> <asp:Label ID="lblNews" runat="server" Text=""></asp:Label> </td> </tr> </table> and heres the code of the button protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { //Set content type in response stream Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + lblTitulo.Text + ".pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); //Render PlaceHolder to temporary stream System.IO.StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); newsTable.RenderControl(htmlWrite); StringReader reader = new StringReader(stringWrite.ToString()); //Create PDF document Document doc = new Document(PageSize.A4); HTMLWorker parser = new HTMLWorker(doc); PdfWriter.GetInstance(doc, Response.OutputStream); doc.Open(); try { //Create a footer that will display page number HeaderFooter footer = new HeaderFooter(new Phrase("This is page: "), true) { Border = Rectangle.NO_BORDER }; doc.Footer = footer; //Parse Html parser.Parse(reader); } catch (Exception ex) { //Display parser errors in PDF. //Parser errors will also be wisible in Debug.Output window in VS Paragraph paragraph = new Paragraph("Error! " + ex.Message); paragraph.SetAlignment("center"); Chunk text = paragraph.Chunks[0] as Chunk; if (text != null) { text.Font.Color = Color.RED; } doc.Add(paragraph); } finally { doc.Close(); } } Or is another way to do it? if i want to keep some css, how can i do it? |
|
|
Re: Its inserting a page breakCan anyone help me? please
|
| Free embeddable forum powered by Nabble | Forum Help |