Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am creating pdf file of a panel in aspx page which has multiple tables and controls with varied designing. But the pdf is created with equal size columns for all tables thus ruining all the formatting. Following is the code used as taken from net.

I cannot design the whole page again, pls suggest to keep the columns size intact.

Thanks in advance

VB
Dim appPath As String = HttpContext.Current.Request.ApplicationPath
      Dim path As String = Server.MapPath(appPath & "/Attachments/Test.pdf")
      Dim sw As New StringWriter()
      Dim hw As New HtmlTextWriter(sw)
      Panel1.RenderControl(hw)

      Dim output = New FileStream(path, FileMode.Create)
      Dim sr As New StringReader(sw.ToString())
      Dim pdfDoc As New iTextSharp.text.Document(PageSize.A4, 10.0F, 10.0F, 50.0F, 0.0F)
      Dim htmlparser As New HTMLWorker(pdfDoc)
      iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, output)
      pdfDoc.Open()
      htmlparser.Parse(sr)
      pdfDoc.Close()
Posted
Updated 2-Sep-15 1:57am
v2

1 solution

Hi,

Check this....

C#
Dim columnWidths_new As Single() = New Single() {5.0F, 30.0F, 15.0F}
           table_new.SetWidths(columnWidths_new)



Hope this will help you.

Cheers
 
Share this answer
 
Comments
atul sharma 5126 2-Sep-15 8:51am    
Thanks for the reply dear !

But as mentioned earlier, I am exporting a panel with already filled multiple tables, grid view etc. And so want to keep the format designed in aspx intact and cannot design whole page from scrach.
Pls suggest !
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900