Mayur  Gujrathi

Mayur Gujrathi

  • 389
  • 3.9k
  • 1m

How to rempve space in words of pdf

Aug 9 2012 9:33 AM
Dear All

I am trying to convert html text to pdf using itextsharp..pdf is generating fine but there is a lot of gap in between words of pdf
...sample pdf file is attached...
In hdpdf.Value i am fetching all html text..
code :

  Dim document As Document = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4.Rotate, 1, 1, 1, 1)
        Dim UrlDirectory As [String] = Request.Url.GetLeftPart(UriPartial.Path)
        UrlDirectory = UrlDirectory.Substring(0, UrlDirectory.LastIndexOf("/") + 1)
        Response.Write(UrlDirectory)
        PdfWriter.GetInstance(document, New FileStream(Server.MapPath(".") + "mayur.pdf", FileMode.Create))

        document.Open()
        '  Dim textFont As Font = FontFactory.GetFont("Helvetica", 1, 1, font.NORMAL, BaseColor.BLACK)
        Dim htmlText As [String] = hdpdf.Value
        Dim htmlarraylist As List(Of IElement) = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(New StringReader(htmlText), Nothing)
        ' document.SetPageSize=
        Dim font As Font = FontFactory.GetFont("Times-Roman", 9)
        For k As Integer = 0 To htmlarraylist.Count - 1
            Dim x As IElement = DirectCast(htmlarraylist(k), IElement)
            Response.Write(x.Type.ToString() + "#<br>")
        Next
        Dim mypara As New Paragraph()
        '    mypara.SetLeading(0.0F, 3.0F)


        mypara.InsertRange(0, htmlarraylist)
        document.Add(mypara)
        document.Close()